net: pse-pd: Introduce PSE types enumeration
authorKory Maincent (Dent Project) <kory.maincent@bootlin.com>
Wed, 17 Apr 2024 14:39:50 +0000 (16:39 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 19 Apr 2024 01:27:01 +0000 (18:27 -0700)
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 <andrew@lunn.ch>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://lore.kernel.org/r/20240417-feature_poe-v9-2-242293fd1900@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/pse-pd/pse_core.c
drivers/net/pse-pd/pse_regulator.c
include/linux/pse-pd/pse.h
include/uapi/linux/ethtool.h

index 146b81f08a890ca93efda3c46e37d28e6c36c1ad..fed006cbc185ff542cd7a400797b010eb0bf49d7 100644 (file)
@@ -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);
index 1dedf4de296e7281c9cbd265d69401711a900932..547af384764bb06caefdfa7ba936f00137ef70e2 100644 (file)
@@ -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",
index be4e5754eb24f7ce67d2a116ed90931f29241383..19589571157f535db5110b62f38d3cc7c179182f 100644 (file)
@@ -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
index 7b9a3d89094920c86d6e3702fb5617efb1b7fce4..041e09c3515d0d69f81cee486a1e3c5864eaaf4c 100644 (file)
@@ -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