Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3352148lqp; Tue, 26 Mar 2024 07:05:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2pYaDWndhcXNslWvNvcykrlA0h1Mun71wOcFbeoQjbhOgvlR5U7Wl4Qcx7Z2XaUDhOU0FkuyLWWDY/S6CtwVukGb9Opp53jJlqCNRDg== X-Google-Smtp-Source: AGHT+IFoIbN/1wJrWsgUcjMKp23vlToLqmzMn8fGytzzpl1oH4IeARApZXoYzchqFtbl9PI3cfUl X-Received: by 2002:a05:6358:7f1c:b0:178:faff:7173 with SMTP id p28-20020a0563587f1c00b00178faff7173mr7717478rwn.22.1711461916606; Tue, 26 Mar 2024 07:05:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711461916; cv=pass; d=google.com; s=arc-20160816; b=cGhMScorAiN48LxT31YtEmmH7ti5l8fp46kFewoTurUAzH0nXNmalNNGvspwIo6PK/ TbpI6q06jBGRerz6yE4S6D1mRsmTrQT/LepI8cudFXxKaykM6TQliI2Bc+xDRT4ElFjW xTSyCDSq7e9gnI8/SUgkDe5ynRJCLPI124UKAv1VxEIKDTmQ3u4XMnNEFlWVyHyZPhix WdaaWtaCt2ojRy4dsqk0PjxcJaxB5nezTYp1ZSAHRXvcsd6TvBd/IwF4nTosuvkJ9SrB p4kkxKh+XyitZsSDL4VAer+OTwJDqD/wpRqS9ylOCFRGePNMpzdhZePH+2TCPEmt2s7U e8/w== 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=ypJN44oI3OAM8rW/9vXFxGoMgSDzSXiK6F6YpMtW4gg=; fh=7S+YztZcCxZKIOm2mMOwIzm96FjMcKQ7LjGMKaNLlnQ=; b=IocImpcxFVS3ZysuQRpOI15ZOtQqrTfeGWx9wj3fcyPvBFIhto3Vq62fVLjYBq6fDe 0Tp6g5FO1ayE5/V7WiCnzBJz3RrckFURCowEla0+sdMV5usU7jGjKYChhUE7/6XAxx/r CuEqV6jz8Ezg20aa3vECgxtWg2j/GFEA4fGG7CqH05cHosiCd3l+7aMejRTYjxLoWWZM p5NjWYR9uramGviR7kgo5x5T5evB6/xJEjfkbku8NMPHDMLLYHSAgnhXPZE8WXmNEVP+ 8WQNFRGS9LzKrixC8W6Ugr8JsdQXdwAKcIsSNCgwDfuhlDlGmRfFgLU71xAOiVO6gMW9 z4oQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gcqSvPf3; 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-119117-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119117-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. [139.178.88.99]) by mx.google.com with ESMTPS id t8-20020a656088000000b005e857e49c80si9560778pgu.435.2024.03.26.07.05.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 07:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119117-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gcqSvPf3; 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-119117-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119117-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 43C002E0E9D for ; Tue, 26 Mar 2024 14:05:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13E0A768E0; Tue, 26 Mar 2024 14:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="gcqSvPf3" Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 22FBA757F9; Tue, 26 Mar 2024 14:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711461898; cv=none; b=dCucJOv3lDWIIM68CcjWZWf10oMgeaqWfv82CjSwK6UYrbJou2nTaQzScMjhTu1yf/mCD0SFNZsRAN994KBlhTrODdkcm8m2YxbU3+q/+BMqZiMgSuPetaWe2gnd8D1HNiSQimQiYuWb0DWBcGhZhglQP2tUxvY/LBT7bhahxME= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711461898; c=relaxed/simple; bh=vmoh7n1NDou4qyy3KTvyy3M/rE/jjwUPhC2NydtM2xY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lQqQjf2FQXKBQfs3Vw9HfHFn8KxouDNYYnalUuY37s1ntadAKg3U+nnH7gtdwd1snjm3J6Oy5og3kcBmPAco0a93YRONt0uqDGyPbpxSywoMUPFVGTGZD6Fv9+P5Lez90hgIETlGoVLySTu6bRGXhDIBhJaHzAnaeDcV1xzTCZU= 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=gcqSvPf3; arc=none smtp.client-ip=217.70.183.197 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 6701A1C0012; Tue, 26 Mar 2024 14:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1711461893; 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=ypJN44oI3OAM8rW/9vXFxGoMgSDzSXiK6F6YpMtW4gg=; b=gcqSvPf3b5bWlkNYXmmPHd5736Xc5U2H9NBiL4NGRZu004wBTfnyHWRXZ6EhnD4ENbfXCm pUbzSL+bnNtazOPHlyTJAwBOP1MBlNlQkPsutHEdpEnkfdIvax3vdsanh2OHph7Nckj7iC iv9IY4I11ppUn39qj1lZmUAWdMJfV5/Y0iZ/rg+d9WxxV+ShiOMFfNbZggmSmqLtz7sKqS atfDLRKwjmdP+IcRdjkyyjXSbR4hQXVrA7Oj/X6KuIixsqmkfDcZdY2FxYwULKqFGm7FLZ y3sVVUd3d8RndPOBYWtsq9BZDVoPx/CTa20JyX2hbhMgrwmlCBKiI3r4YLN8Rg== From: Kory Maincent Date: Tue, 26 Mar 2024 15:04:42 +0100 Subject: [PATCH net-next v6 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: <20240326-feature_poe-v6-5-c1011b6ea1cb@bootlin.com> References: <20240326-feature_poe-v6-0-c1011b6ea1cb@bootlin.com> In-Reply-To: <20240326-feature_poe-v6-0-c1011b6ea1cb@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 , 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 b2f7906c7c5b..f920964e096a 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.25.1