Commit 33d21bd1 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net: Add support for Power over Ethernet (PoE)'

Kory Maincent says:

====================
net: Add support for Power over Ethernet (PoE)

This patch series aims at adding support for PoE (Power over Ethernet),
based on the already existing support for PoDL (Power over Data Line)
implementation. In addition, it adds support for two specific PoE
controller, the Microchip PD692x0 and the TI TPS23881.
====================

Link: https://lore.kernel.org/all/20240417-feature_poe-v9-0-242293fd1900@bootlin.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 80d953c8 20e6d190
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/pse-pd/microchip,pd692x0.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Microchip PD692x0 Power Sourcing Equipment controller
maintainers:
- Kory Maincent <kory.maincent@bootlin.com>
allOf:
- $ref: pse-controller.yaml#
properties:
compatible:
enum:
- microchip,pd69200
- microchip,pd69210
- microchip,pd69220
reg:
maxItems: 1
managers:
type: object
description:
List of the PD69208T4/PD69204T4/PD69208M PSE managers. Each manager
have 4 or 8 physical ports according to the chip version. No need to
specify the SPI chip select as it is automatically detected by the
PD692x0 PSE controller. The PSE managers have to be described from
the lowest chip select to the greatest one, which is the detection
behavior of the PD692x0 PSE controller. The PD692x0 support up to
12 PSE managers which can expose up to 96 physical ports. All
physical ports available on a manager have to be described in the
incremental order even if they are not used.
properties:
"#address-cells":
const: 1
"#size-cells":
const: 0
required:
- "#address-cells"
- "#size-cells"
patternProperties:
"^manager@0[0-9a-b]$":
type: object
description:
PD69208T4/PD69204T4/PD69208M PSE manager exposing 4 or 8 physical
ports.
properties:
reg:
description:
Incremental index of the PSE manager starting from 0, ranging
from lowest to highest chip select, up to 11.
maxItems: 1
"#address-cells":
const: 1
"#size-cells":
const: 0
patternProperties:
'^port@[0-7]$':
type: object
required:
- reg
additionalProperties: false
required:
- reg
- "#address-cells"
- "#size-cells"
required:
- compatible
- reg
- pse-pis
unevaluatedProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
ethernet-pse@3c {
compatible = "microchip,pd69200";
reg = <0x3c>;
managers {
#address-cells = <1>;
#size-cells = <0>;
manager@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
phys0: port@0 {
reg = <0>;
};
phys1: port@1 {
reg = <1>;
};
phys2: port@2 {
reg = <2>;
};
phys3: port@3 {
reg = <3>;
};
};
manager@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
phys4: port@0 {
reg = <0>;
};
phys5: port@1 {
reg = <1>;
};
phys6: port@2 {
reg = <2>;
};
phys7: port@3 {
reg = <3>;
};
};
};
pse-pis {
#address-cells = <1>;
#size-cells = <0>;
pse_pi0: pse-pi@0 {
reg = <0>;
#pse-cells = <0>;
pairset-names = "alternative-a", "alternative-b";
pairsets = <&phys0>, <&phys1>;
polarity-supported = "MDI", "S";
vpwr-supply = <&vpwr1>;
};
pse_pi1: pse-pi@1 {
reg = <1>;
#pse-cells = <0>;
pairset-names = "alternative-a";
pairsets = <&phys2>;
polarity-supported = "MDI";
vpwr-supply = <&vpwr2>;
};
};
};
};
......@@ -13,6 +13,7 @@ description: Binding for the Power Sourcing Equipment (PSE) as defined in the
maintainers:
- Oleksij Rempel <o.rempel@pengutronix.de>
- Kory Maincent <kory.maincent@bootlin.com>
properties:
$nodename:
......@@ -22,11 +23,105 @@ properties:
description:
Used to uniquely identify a PSE instance within an IC. Will be
0 on PSE nodes with only a single output and at least 1 on nodes
controlling several outputs.
controlling several outputs which are not described in the pse-pis
subnode. This property is deprecated, please use pse-pis instead.
enum: [0, 1]
required:
- "#pse-cells"
pse-pis:
type: object
description:
Overview of the PSE PIs provided by the controller.
properties:
"#address-cells":
const: 1
"#size-cells":
const: 0
required:
- "#address-cells"
- "#size-cells"
patternProperties:
"^pse-pi@[0-9a-f]+$":
type: object
description:
PSE PI for power delivery via pairsets, compliant with IEEE
802.3-2022, Section 145.2.4. Each pairset comprises a positive and
a negative VPSE pair, adhering to the pinout configurations
detailed in the standard.
See Documentation/networking/pse-pd/pse-pi.rst for details.
properties:
reg:
description:
Address describing the PSE PI index.
maxItems: 1
"#pse-cells":
const: 0
pairset-names:
$ref: /schemas/types.yaml#/definitions/string-array
description:
Names of the pairsets as per IEEE 802.3-2022, Section 145.2.4.
Each name should correspond to a phandle in the 'pairset'
property pointing to the power supply for that pairset.
minItems: 1
maxItems: 2
items:
enum:
- alternative-a
- alternative-b
pairsets:
$ref: /schemas/types.yaml#/definitions/phandle-array
description:
List of phandles, each pointing to the power supply for the
corresponding pairset named in 'pairset-names'. This property
aligns with IEEE 802.3-2022, Section 33.2.3 and 145.2.4.
PSE Pinout Alternatives (as per IEEE 802.3-2022 Table 145\u20133)
|-----------|---------------|---------------|---------------|---------------|
| Conductor | Alternative A | Alternative A | Alternative B | Alternative B |
| | (MDI-X) | (MDI) | (X) | (S) |
|-----------|---------------|---------------|---------------|---------------|
| 1 | Negative VPSE | Positive VPSE | - | - |
| 2 | Negative VPSE | Positive VPSE | - | - |
| 3 | Positive VPSE | Negative VPSE | - | - |
| 4 | - | - | Negative VPSE | Positive VPSE |
| 5 | - | - | Negative VPSE | Positive VPSE |
| 6 | Positive VPSE | Negative VPSE | - | - |
| 7 | - | - | Positive VPSE | Negative VPSE |
| 8 | - | - | Positive VPSE | Negative VPSE |
minItems: 1
maxItems: 2
polarity-supported:
$ref: /schemas/types.yaml#/definitions/string-array
description:
Polarity configuration supported by the PSE PI pairsets.
minItems: 1
maxItems: 4
items:
enum:
- MDI-X
- MDI
- X
- S
vpwr-supply:
description: Regulator power supply for the PSE PI.
required:
- reg
- "#pse-cells"
oneOf:
- required:
- "#pse-cells"
- required:
- pse-pis
additionalProperties: true
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/pse-pd/ti,tps23881.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: TI TPS23881 Power Sourcing Equipment controller
maintainers:
- Kory Maincent <kory.maincent@bootlin.com>
allOf:
- $ref: pse-controller.yaml#
properties:
compatible:
enum:
- ti,tps23881
reg:
maxItems: 1
'#pse-cells':
const: 1
channels:
description: each set of 8 ports can be assigned to one physical
channels or two for PoE4. This parameter describes the configuration
of the ports conversion matrix that establishes relationship between
the logical ports and the physical channels.
type: object
patternProperties:
'^channel@[0-7]$':
type: object
required:
- reg
unevaluatedProperties: false
required:
- compatible
- reg
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
ethernet-pse@20 {
compatible = "ti,tps23881";
reg = <0x20>;
channels {
#address-cells = <1>;
#size-cells = <0>;
phys0: channel@0 {
reg = <0>;
};
phys1: channel@1 {
reg = <1>;
};
phys2: channel@2 {
reg = <2>;
};
};
pse-pis {
#address-cells = <1>;
#size-cells = <0>;
pse_pi0: pse-pi@0 {
reg = <0>;
#pse-cells = <0>;
pairset-names = "alternative-a", "alternative-b";
pairsets = <&phys0>, <&phys1>;
polarity-supported = "MDI", "S";
vpwr-supply = <&vpwr1>;
};
pse_pi1: pse-pi@1 {
reg = <1>;
#pse-cells = <0>;
pairset-names = "alternative-a";
pairsets = <&phys2>;
polarity-supported = "MDI";
vpwr-supply = <&vpwr2>;
};
};
};
};
......@@ -899,17 +899,29 @@ attribute-sets:
type: nest
nested-attributes: header
-
name: admin-state
name: podl-pse-admin-state
type: u32
name-prefix: ethtool-a-podl-pse-
name-prefix: ethtool-a-
-
name: admin-control
name: podl-pse-admin-control
type: u32
name-prefix: ethtool-a-podl-pse-
name-prefix: ethtool-a-
-
name: pw-d-status
name: podl-pse-pw-d-status
type: u32
name-prefix: ethtool-a-podl-pse-
name-prefix: ethtool-a-
-
name: c33-pse-admin-state
type: u32
name-prefix: ethtool-a-
-
name: c33-pse-admin-control
type: u32
name-prefix: ethtool-a-
-
name: c33-pse-pw-d-status
type: u32
name-prefix: ethtool-a-
-
name: rss
attributes:
......@@ -1593,9 +1605,12 @@ operations:
reply:
attributes: &pse
- header
- admin-state
- admin-control
- pw-d-status
- podl-pse-admin-state
- podl-pse-admin-control
- podl-pse-pw-d-status
- c33-pse-admin-state
- c33-pse-admin-control
- c33-pse-pw-d-status
dump: *pse-get-op
-
name: pse-set
......
......@@ -1733,6 +1733,10 @@ Kernel response contents:
PSE functions
``ETHTOOL_A_PODL_PSE_PW_D_STATUS`` u32 power detection status of the
PoDL PSE.
``ETHTOOL_A_C33_PSE_ADMIN_STATE`` u32 Operational state of the PoE
PSE functions.
``ETHTOOL_A_C33_PSE_PW_D_STATUS`` u32 power detection status of the
PoE PSE.
====================================== ====== =============================
When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` attribute identifies
......@@ -1744,6 +1748,12 @@ aPoDLPSEAdminState. Possible values are:
.. kernel-doc:: include/uapi/linux/ethtool.h
:identifiers: ethtool_podl_pse_admin_state
The same goes for ``ETHTOOL_A_C33_PSE_ADMIN_STATE`` implementing
``IEEE 802.3-2022`` 30.9.1.1.2 aPSEAdminState.
.. kernel-doc:: include/uapi/linux/ethtool.h
:identifiers: ethtool_c33_pse_admin_state
When set, the optional ``ETHTOOL_A_PODL_PSE_PW_D_STATUS`` attribute identifies
the power detection status of the PoDL PSE. The status depend on internal PSE
state machine and automatic PD classification support. This option is
......@@ -1753,6 +1763,12 @@ Possible values are:
.. kernel-doc:: include/uapi/linux/ethtool.h
:identifiers: ethtool_podl_pse_pw_d_status
The same goes for ``ETHTOOL_A_C33_PSE_ADMIN_PW_D_STATUS`` implementing
``IEEE 802.3-2022`` 30.9.1.1.5 aPSEPowerDetectionStatus.
.. kernel-doc:: include/uapi/linux/ethtool.h
:identifiers: ethtool_c33_pse_pw_d_status
PSE_SET
=======
......@@ -1763,6 +1779,7 @@ Request contents:
====================================== ====== =============================
``ETHTOOL_A_PSE_HEADER`` nested request header
``ETHTOOL_A_PODL_PSE_ADMIN_CONTROL`` u32 Control PoDL PSE Admin state
``ETHTOOL_A_C33_PSE_ADMIN_CONTROL`` u32 Control PSE Admin state
====================================== ====== =============================
When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_CONTROL`` attribute is used
......@@ -1770,6 +1787,9 @@ to control PoDL PSE Admin functions. This option is implementing
``IEEE 802.3-2018`` 30.15.1.2.1 acPoDLPSEAdminControl. See
``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` for supported values.
The same goes for ``ETHTOOL_A_C33_PSE_ADMIN_CONTROL`` implementing
``IEEE 802.3-2022`` 30.9.1.2.1 acPSEAdminControl.
RSS_GET
=======
......
......@@ -93,6 +93,7 @@ Contents:
plip
ppp_generic
proc_net_tcp
pse-pd/index
radiotap-headers
rds
regulatory
......
.. SPDX-License-Identifier: GPL-2.0
Power Sourcing Equipment (PSE) Documentation
============================================
.. toctree::
:maxdepth: 2
introduction
pse-pi
.. SPDX-License-Identifier: GPL-2.0
Power Sourcing Equipment (PSE) in IEEE 802.3 Standard
=====================================================
Overview
--------
Power Sourcing Equipment (PSE) is essential in networks for delivering power
along with data over Ethernet cables. It usually refers to devices like
switches and hubs that supply power to Powered Devices (PDs) such as IP
cameras, VoIP phones, and wireless access points.
PSE vs. PoDL PSE
----------------
PSE in the IEEE 802.3 standard generally refers to equipment that provides
power alongside data over Ethernet cables, typically associated with Power over
Ethernet (PoE).
PoDL PSE, or Power over Data Lines PSE, specifically denotes PSEs operating
with single balanced twisted-pair PHYs, as per Clause 104 of IEEE 802.3. PoDL
is significant in contexts like automotive and industrial controls where power
and data delivery over a single pair is advantageous.
IEEE 802.3-2018 Addendums and Related Clauses
---------------------------------------------
Key addenda to the IEEE 802.3-2018 standard relevant to power delivery over
Ethernet are as follows:
- **802.3af (Approved in 2003-06-12)**: Known as PoE in the market, detailed in
Clause 33, delivering up to 15.4W of power.
- **802.3at (Approved in 2009-09-11)**: Marketed as PoE+, enhancing PoE as
covered in Clause 33, increasing power delivery to up to 30W.
- **802.3bt (Approved in 2018-09-27)**: Known as 4PPoE in the market, outlined
in Clause 33. Type 3 delivers up to 60W, and Type 4 up to 100W.
- **802.3bu (Approved in 2016-12-07)**: Formerly referred to as PoDL, detailed
in Clause 104. Introduces Classes 0 - 9. Class 9 PoDL PSE delivers up to ~65W
Kernel Naming Convention Recommendations
----------------------------------------
For clarity and consistency within the Linux kernel's networking subsystem, the
following naming conventions are recommended:
- For general PSE (PoE) code, use "c33_pse" key words. For example:
``enum ethtool_c33_pse_admin_state c33_admin_control;``.
This aligns with Clause 33, encompassing various PoE forms.
- For PoDL PSE - specific code, use "podl_pse". For example:
``enum ethtool_podl_pse_admin_state podl_admin_control;`` to differentiate
PoDL PSE settings according to Clause 104.
Summary of Clause 33: Data Terminal Equipment (DTE) Power via Media Dependent Interface (MDI)
---------------------------------------------------------------------------------------------
Clause 33 of the IEEE 802.3 standard defines the functional and electrical
characteristics of Powered Device (PD) and Power Sourcing Equipment (PSE).
These entities enable power delivery using the same generic cabling as for data
transmission, integrating power with data communication for devices such as
10BASE-T, 100BASE-TX, or 1000BASE-T.
Summary of Clause 104: Power over Data Lines (PoDL) of Single Balanced Twisted-Pair Ethernet
--------------------------------------------------------------------------------------------
Clause 104 of the IEEE 802.3 standard delineates the functional and electrical
characteristics of PoDL Powered Devices (PDs) and PoDL Power Sourcing Equipment
(PSEs). These are designed for use with single balanced twisted-pair Ethernet
Physical Layers. In this clause, 'PSE' refers specifically to PoDL PSE, and
'PD' to PoDL PD. The key intent is to provide devices with a unified interface
for both data and the power required to process this data over a single
balanced twisted-pair Ethernet connection.
This diff is collapsed.
......@@ -17779,6 +17779,7 @@ F: net/psample
PSE NETWORK DRIVER
M: Oleksij Rempel <o.rempel@pengutronix.de>
M: Kory Maincent <kory.maincent@bootlin.com>
L: netdev@vger.kernel.org
S: Maintained
F: Documentation/devicetree/bindings/net/pse-pd/
......
......@@ -20,4 +20,24 @@ config PSE_REGULATOR
Sourcing Equipment without automatic classification support. For
example for basic implementation of PoDL (802.3bu) specification.
config PSE_PD692X0
tristate "PD692X0 PSE controller"
depends on I2C
select FW_UPLOAD
help
This module provides support for PD692x0 regulator based Ethernet
Power Sourcing Equipment.
To compile this driver as a module, choose M here: the
module will be called pd692x0.
config PSE_TPS23881
tristate "TPS23881 PSE controller"
depends on I2C
help
This module provides support for TPS23881 regulator based Ethernet
Power Sourcing Equipment.
To compile this driver as a module, choose M here: the
module will be called tps23881.
endif
......@@ -4,3 +4,5 @@
obj-$(CONFIG_PSE_CONTROLLER) += pse_core.o
obj-$(CONFIG_PSE_REGULATOR) += pse_regulator.o
obj-$(CONFIG_PSE_PD692X0) += pd692x0.o
obj-$(CONFIG_PSE_TPS23881) += tps23881.o
This diff is collapsed.
This diff is collapsed.
......@@ -24,37 +24,41 @@ static struct pse_reg_priv *to_pse_reg(struct pse_controller_dev *pcdev)
}
static int
pse_reg_ethtool_set_config(struct pse_controller_dev *pcdev, unsigned long id,
struct netlink_ext_ack *extack,
const struct pse_control_config *config)
pse_reg_pi_enable(struct pse_controller_dev *pcdev, int id)
{
struct pse_reg_priv *priv = to_pse_reg(pcdev);
int ret;
if (priv->admin_state == config->podl_admin_control)
return 0;
switch (config->podl_admin_control) {
case ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED:
ret = regulator_enable(priv->ps);
break;
case ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED:
ret = regulator_disable(priv->ps);
break;
default:
dev_err(pcdev->dev, "Unknown admin state %i\n",
config->podl_admin_control);
ret = -ENOTSUPP;
}
ret = regulator_enable(priv->ps);
if (ret)
return ret;
priv->admin_state = config->podl_admin_control;
priv->admin_state = ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED;
return 0;
}
static int
pse_reg_pi_disable(struct pse_controller_dev *pcdev, int id)
{
struct pse_reg_priv *priv = to_pse_reg(pcdev);
int ret;
ret = regulator_disable(priv->ps);
if (ret)
return ret;
priv->admin_state = ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED;
return 0;
}
static int
pse_reg_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
{
struct pse_reg_priv *priv = to_pse_reg(pcdev);
return regulator_is_enabled(priv->ps);
}
static int
pse_reg_ethtool_get_status(struct pse_controller_dev *pcdev, unsigned long id,
struct netlink_ext_ack *extack,
......@@ -80,7 +84,9 @@ pse_reg_ethtool_get_status(struct pse_controller_dev *pcdev, unsigned long id,
static const struct pse_controller_ops pse_reg_ops = {
.ethtool_get_status = pse_reg_ethtool_get_status,
.ethtool_set_config = pse_reg_ethtool_set_config,
.pi_enable = pse_reg_pi_enable,
.pi_is_enabled = pse_reg_pi_is_enabled,
.pi_disable = pse_reg_pi_disable,
};
static int
......@@ -116,6 +122,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",
......
This diff is collapsed.
......@@ -17,9 +17,12 @@ struct pse_controller_dev;
*
* @podl_admin_control: set PoDL PSE admin control as described in
* IEEE 802.3-2018 30.15.1.2.1 acPoDLPSEAdminControl
* @c33_admin_control: set PSE admin control as described in
* IEEE 802.3-2022 30.9.1.2.1 acPSEAdminControl
*/
struct pse_control_config {
enum ethtool_podl_pse_admin_state podl_admin_control;
enum ethtool_c33_pse_admin_state c33_admin_control;
};
/**
......@@ -29,25 +32,36 @@ struct pse_control_config {
* functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
* @podl_pw_status: power detection status of the PoDL PSE.
* IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus:
* @c33_admin_state: operational state of the PSE
* functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState
* @c33_pw_status: power detection status of the PSE.
* IEEE 802.3-2022 30.9.1.1.5 aPSEPowerDetectionStatus:
*/
struct pse_control_status {
enum ethtool_podl_pse_admin_state podl_admin_state;
enum ethtool_podl_pse_pw_d_status podl_pw_status;
enum ethtool_c33_pse_admin_state c33_admin_state;
enum ethtool_c33_pse_pw_d_status c33_pw_status;
};
/**
* struct pse_controller_ops - PSE controller driver callbacks
*
* @ethtool_get_status: get PSE control status for ethtool interface
* @ethtool_set_config: set PSE control configuration over ethtool interface
* @setup_pi_matrix: setup PI matrix of the PSE controller
* @pi_is_enabled: Return 1 if the PSE PI is enabled, 0 if not.
* May also return negative errno.
* @pi_enable: Configure the PSE PI as enabled.
* @pi_disable: Configure the PSE PI as disabled.
*/
struct pse_controller_ops {
int (*ethtool_get_status)(struct pse_controller_dev *pcdev,
unsigned long id, struct netlink_ext_ack *extack,
struct pse_control_status *status);
int (*ethtool_set_config)(struct pse_controller_dev *pcdev,
unsigned long id, struct netlink_ext_ack *extack,
const struct pse_control_config *config);
int (*setup_pi_matrix)(struct pse_controller_dev *pcdev);
int (*pi_is_enabled)(struct pse_controller_dev *pcdev, int id);
int (*pi_enable)(struct pse_controller_dev *pcdev, int id);
int (*pi_disable)(struct pse_controller_dev *pcdev, int id);
};
struct module;
......@@ -55,6 +69,40 @@ struct device_node;
struct of_phandle_args;
struct pse_control;
/* PSE PI pairset pinout can either be Alternative A or Alternative B */
enum pse_pi_pairset_pinout {
ALTERNATIVE_A,
ALTERNATIVE_B,
};
/**
* struct pse_pi_pairset - PSE PI pairset entity describing the pinout
* alternative ant its phandle
*
* @pinout: description of the pinout alternative
* @np: device node pointer describing the pairset phandle
*/
struct pse_pi_pairset {
enum pse_pi_pairset_pinout pinout;
struct device_node *np;
};
/**
* struct pse_pi - PSE PI (Power Interface) entity as described in
* IEEE 802.3-2022 145.2.4
*
* @pairset: table of the PSE PI pinout alternative for the two pairset
* @np: device node pointer of the PSE PI node
* @rdev: regulator represented by the PSE PI
* @admin_state_enabled: PI enabled state
*/
struct pse_pi {
struct pse_pi_pairset pairset[2];
struct device_node *np;
struct regulator_dev *rdev;
bool admin_state_enabled;
};
/**
* struct pse_controller_dev - PSE controller entity that might
* provide multiple PSE controls
......@@ -64,10 +112,11 @@ struct pse_control;
* @pse_control_head: head of internal list of requested PSE controls
* @dev: corresponding driver model device struct
* @of_pse_n_cells: number of cells in PSE line specifiers
* @of_xlate: translation function to translate from specifier as found in the
* 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
* @pi: table of PSE PIs described in this controller device
* @no_of_pse_pi: flag set if the pse_pis devicetree node is not used
*/
struct pse_controller_dev {
const struct pse_controller_ops *ops;
......@@ -76,10 +125,11 @@ struct pse_controller_dev {
struct list_head pse_control_head;
struct device *dev;
int of_pse_n_cells;
int (*of_xlate)(struct pse_controller_dev *pcdev,
const struct of_phandle_args *pse_spec);
unsigned int nr_lines;
struct mutex lock;
enum ethtool_pse_types types;
struct pse_pi *pi;
bool no_of_pse_pi;
};
#if IS_ENABLED(CONFIG_PSE_CONTROLLER)
......@@ -99,6 +149,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)
......@@ -124,6 +177,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
......@@ -752,6 +752,61 @@ 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
* @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown
* @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled
* @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled
*/
enum ethtool_c33_pse_admin_state {
ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN = 1,
ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED,
ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED,
};
/**
* enum ethtool_c33_pse_pw_d_status - power detection status of the PSE.
* IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus:
* @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown
* @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled"
* indicates that the PSE State diagram is in the state DISABLED.
* @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching"
* indicates the PSE State diagram is in a state other than those
* listed.
* @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration
* "deliveringPower" indicates that the PSE State diagram is in the
* state POWER_ON.
* @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that
* the PSE State diagram is in the state TEST_MODE.
* @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates that
* the PSE State diagram is in the state TEST_ERROR.
* @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault"
* indicates that the PSE State diagram is in the state IDLE due to
* the variable error_condition = true.
*/
enum ethtool_c33_pse_pw_d_status {
ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN = 1,
ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED,
ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING,
ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING,
ETHTOOL_C33_PSE_PW_D_STATUS_TEST,
ETHTOOL_C33_PSE_PW_D_STATUS_FAULT,
ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT,
};
/**
* enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE
* functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
......
......@@ -913,6 +913,9 @@ enum {
ETHTOOL_A_PODL_PSE_ADMIN_STATE, /* u32 */
ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, /* u32 */
ETHTOOL_A_PODL_PSE_PW_D_STATUS, /* u32 */
ETHTOOL_A_C33_PSE_ADMIN_STATE, /* u32 */
ETHTOOL_A_C33_PSE_ADMIN_CONTROL, /* u32 */
ETHTOOL_A_C33_PSE_PW_D_STATUS, /* u32 */
/* add new constants above here */
__ETHTOOL_A_PSE_CNT,
......
......@@ -82,6 +82,10 @@ static int pse_reply_size(const struct ethnl_req_info *req_base,
len += nla_total_size(sizeof(u32)); /* _PODL_PSE_ADMIN_STATE */
if (st->podl_pw_status > 0)
len += nla_total_size(sizeof(u32)); /* _PODL_PSE_PW_D_STATUS */
if (st->c33_admin_state > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_ADMIN_STATE */
if (st->c33_pw_status > 0)
len += nla_total_size(sizeof(u32)); /* _C33_PSE_PW_D_STATUS */
return len;
}
......@@ -103,6 +107,16 @@ static int pse_fill_reply(struct sk_buff *skb,
st->podl_pw_status))
return -EMSGSIZE;
if (st->c33_admin_state > 0 &&
nla_put_u32(skb, ETHTOOL_A_C33_PSE_ADMIN_STATE,
st->c33_admin_state))
return -EMSGSIZE;
if (st->c33_pw_status > 0 &&
nla_put_u32(skb, ETHTOOL_A_C33_PSE_PW_D_STATUS,
st->c33_pw_status))
return -EMSGSIZE;
return 0;
}
......@@ -113,25 +127,18 @@ const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1] = {
[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL] =
NLA_POLICY_RANGE(NLA_U32, ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED,
ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED),
[ETHTOOL_A_C33_PSE_ADMIN_CONTROL] =
NLA_POLICY_RANGE(NLA_U32, ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED,
ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED),
};
static int
ethnl_set_pse_validate(struct ethnl_req_info *req_info, struct genl_info *info)
{
return !!info->attrs[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL];
}
static int
ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)
{
struct net_device *dev = req_info->dev;
struct pse_control_config config = {};
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
/* this values are already validated by the ethnl_pse_set_policy */
config.podl_admin_control = nla_get_u32(tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]);
phydev = dev->phydev;
if (!phydev) {
NL_SET_ERR_MSG(info->extack, "No PHY is attached");
......@@ -143,6 +150,39 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)
return -EOPNOTSUPP;
}
if (tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL] &&
!pse_has_podl(phydev->psec)) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL],
"setting PoDL PSE admin control not supported");
return -EOPNOTSUPP;
}
if (tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL] &&
!pse_has_c33(phydev->psec)) {
NL_SET_ERR_MSG_ATTR(info->extack,
tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL],
"setting C33 PSE admin control not supported");
return -EOPNOTSUPP;
}
return 1;
}
static int
ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)
{
struct net_device *dev = req_info->dev;
struct pse_control_config config = {};
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
phydev = dev->phydev;
/* These values are already validated by the ethnl_pse_set_policy */
if (pse_has_podl(phydev->psec))
config.podl_admin_control = nla_get_u32(tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]);
if (pse_has_c33(phydev->psec))
config.c33_admin_control = nla_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL]);
/* Return errno directly - PSE has no notification */
return pse_ethtool_set_config(phydev->psec, info->extack, &config);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment