Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2052054lqe; Tue, 9 Apr 2024 08:15:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrhff+CiCxXbiplStcKmAIUmbXUeWPg9Z2wHKKnMH9R45R78Ic7aMgjtLMbKjh0Udu7+ZW0AeUFyMkaXt5IeTedVBvAeWRZvbd3kj2SQ== X-Google-Smtp-Source: AGHT+IEXl8gGmari4spbzNt1UMrBvJMxv9h0uKexlXcWJr4cis0C9pmBzCeVP55Y8kPYn+gqin1t X-Received: by 2002:a05:6a00:139c:b0:6e6:b71f:e80b with SMTP id t28-20020a056a00139c00b006e6b71fe80bmr14976260pfg.7.1712675743140; Tue, 09 Apr 2024 08:15:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712675743; cv=pass; d=google.com; s=arc-20160816; b=jp3Fs1soVa7fD3tP1/vwa9AaznQQdXzXpEn2BILHdmuHuZa/b/zKCAvblxRdyN2oX2 ATA636+KuuCzeGdsSvJP7JMtO6I+gXFGnNasB3fmBi8qbINzlThD2L/bHi6aWuaXAMAX 9BMczHxSGS7gcMFunJw3WYJOOBog9fzqtoDLVfjisF2ER0Vr/0/E6sfYoAhL/ptKlLz8 QU/7NvnTs6qYbbpI+0SB9jcY2oqxPfcOCF45EpUzNZ5TI2qm9CLG+ZB0JlL4M6q1vE/6 xLIjWKcD8xr6vR7/dsGoQz4DqER/YHAOrLiLlCBkeZZ6/0pWl8un0xdb6mOhBtJEsyHi 60kg== 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=tuBeBEFzfxFciEh9P/qLwwCzD9A35ZVUO878Zx4hymqqffwnP/os56JIus92nXRun/ dhFGh2Zd6Y8guxIYwyUrPVJQdJO/jNCOjiTgSrFbMB7QNY0M47yNMVqkHCzmhNckxaqO LFCtgvG+3n78IwI41MDe713DVJt8zqxozQHkg0AanOoD2XkF/R/jaufDYk/PGAM1jOIs Hnu/XW1GMLm5nNC9wdbm9+FGf19+B9/1ZO9BGvvYsWG0nCw7kXMAbiPkFW29NALA7uBo vcbhja9n67ulICYiFLLPuQR5yHufi4KvFlrg1ehj41QHAtbIIkWCBlIecfxUxDtMkMjM 8/vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=P6xfmbol; 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-137160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137160-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 y22-20020aa78556000000b006ecf9d23c47si8687498pfn.23.2024.04.09.08.15.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 08:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137160-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=P6xfmbol; 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-137160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137160-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 DA96C28A55B for ; Tue, 9 Apr 2024 15:05:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D96E131195; Tue, 9 Apr 2024 15:04:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="P6xfmbol" 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 7A2F212FF84; Tue, 9 Apr 2024 15:04:25 +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=1712675068; cv=none; b=ii+oVLXSLeyRXzG3dN7SgrJdQCkcEjdM3cRj8LYjU859jSsID4vEGp66TWj2C3Np5IbW3PnbYiWmulGaQvWX/armCXvo3H76Z731RXhbgtC7b/UibidI8/C70w+mFPNb1Ipb0QYJkpT1FRVL369g/jyx9TgyduiyJJGbP3qXuMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712675068; c=relaxed/simple; bh=dtSdtLY5S1JCjKQc288BE2kE0KGyNXIy8KTYVYnl+8k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hx8gKz7OPMVyy72zI4xSr2mKs71zG4xhZKQGZn7wKRc9Lufw0NyHbzshMOtcdXMi2pe6l+w2gD3gnuAP/KcPRPiSyHgrnidVkcTL8yKhaxMTQtlY6/JFouvRTxZb2awjq9EhvD0rXwWlsEwZzSug7v8snoxVhHyY7ZWZvaYYErM= 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=P6xfmbol; 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 9071EC000E; Tue, 9 Apr 2024 15:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712675064; 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=P6xfmboll6gp0BpYGWTZ6MH6b2K6J9VTQUJh9D0DQzXxVmR6IVMWrhzQDNdlblNX1lKuza oHy1ECTDMESTxVT6NMnMO21E02PiFR78nX+wH98TYP2aWp1JT/JjmvVrNJ04BdH/jPD2Vv CiXHwCzXtj5Aor+oA8WllzXxZPqWvhPL0sq2uHVkZjvB7O0wFLJTCuS6dtv7wiydCQIFkv RDF0Zie53k1WeiB4sQ5JLVheWCnzak7S7FLHG8u0uYoEAEALHERQk4985z/ciDD+TOv3eF B/d6LCaWi4C9zg35g4n8d00fg64r93b4r2pCTUo1JtmiIeUaw8jRRU4wZby0ig== From: Kory Maincent Date: Tue, 09 Apr 2024 17:03:55 +0200 Subject: [PATCH net-next v7 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: <20240409-feature_poe-v7-5-11e38efd4dee@bootlin.com> References: <20240409-feature_poe-v7-0-11e38efd4dee@bootlin.com> In-Reply-To: <20240409-feature_poe-v7-0-11e38efd4dee@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