Commit 757639ac authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'add-support-for-pse-budget-evaluation-strategy'

Kory Maincent says:

====================
Add support for PSE budget evaluation strategy

This series brings support for budget evaluation strategy in the PSE
subsystem. PSE controllers can set priorities to decide which ports should
be turned off in case of special events like over-current.

This patch series adds support for two budget evaluation strategy.
1. Static Method:

   This method involves distributing power based on PD classification.
   It’s straightforward and stable, the PSE core keeping track of the
   budget and subtracting the power requested by each PD’s class.

   Advantages: Every PD gets its promised power at any time, which
   guarantees reliability.

   Disadvantages: PD classification steps are large, meaning devices
   request much more power than they actually need. As a result, the power
   supply may only operate at, say, 50% capacity, which is inefficient and
   wastes money.

2. Dynamic Method:

   To address the inefficiencies of the static method, vendors like
   Microchip have introduced dynamic power budgeting, as seen in the
   PD692x0 firmware. This method monitors the current consumption per port
   and subtracts it from the available power budget. When the budget is
   exceeded, lower-priority ports are shut down.

   Advantages: This method optimizes resource utilization, saving costs.

   Disadvantages: Low-priority devices may experience instability.

The UAPI allows adding support for software port priority mode managed from
userspace later if needed.

Patches 1-2: Add support for interrupt event report in PSE core, ethtool
	     and ethtool specs.
Patch 3: Adds support for interrupt and event report in TPS23881 driver.
Patches 4,5: Add support for PSE power domain in PSE core and ethtool.
Patches 6-8: Add support for budget evaluation strategy in PSE core,
	     ethtool and ethtool specs.
Patches 9-11: Add support for port priority and power supplies in PD692x0
	      drivers.
Patches 12,13: Add support for port priority in TPS23881 drivers.
====================

Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-0-78a1a645e2ee@bootlin.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a5b4e4f4 82566eb4
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -22,6 +22,12 @@ properties:
  reg:
    maxItems: 1

  vdd-supply:
    description: Regulator that provides 3.3V VDD power supply.

  vdda-supply:
    description: Regulator that provides 3.3V VDDA power supply.

  managers:
    type: object
    additionalProperties: false
@@ -68,6 +74,15 @@ properties:
          "#size-cells":
            const: 0

          vmain-supply:
            description: Regulator that provides 44-57V VMAIN power supply.

          vaux5-supply:
            description: Regulator that provides 5V VAUX5 power supply.

          vaux3p3-supply:
            description: Regulator that provides 3.3V VAUX3P3 power supply.

        patternProperties:
          '^port@[0-7]$':
            type: object
@@ -106,10 +121,11 @@ examples:
          #address-cells = <1>;
          #size-cells = <0>;

          manager@0 {
          manager0: manager@0 {
            reg = <0>;
            #address-cells = <1>;
            #size-cells = <0>;
            vmain-supply = <&pse1_supply>;

            phys0: port@0 {
              reg = <0>;
@@ -161,7 +177,7 @@ examples:
            pairset-names = "alternative-a", "alternative-b";
            pairsets = <&phys0>, <&phys1>;
            polarity-supported = "MDI", "S";
            vpwr-supply = <&vpwr1>;
            vpwr-supply = <&manager0>;
          };
          pse_pi1: pse-pi@1 {
            reg = <1>;
@@ -169,7 +185,7 @@ examples:
            pairset-names = "alternative-a";
            pairsets = <&phys2>;
            polarity-supported = "MDI";
            vpwr-supply = <&vpwr2>;
            vpwr-supply = <&manager0>;
          };
        };
      };
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ properties:
  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  '#pse-cells':
    const: 1

@@ -62,9 +65,12 @@ unevaluatedProperties: false
required:
  - compatible
  - reg
  - interrupts

examples:
  - |
    #include <dt-bindings/interrupt-controller/irq.h>

    i2c {
      #address-cells = <1>;
      #size-cells = <0>;
@@ -72,6 +78,8 @@ examples:
      ethernet-pse@20 {
        compatible = "ti,tps23881";
        reg = <0x20>;
        interrupts = <8 IRQ_TYPE_LEVEL_HIGH>;
        interrupt-parent = <&gpiog>;

        channels {
          #address-cells = <1>;
+76 −0
Original line number Diff line number Diff line
@@ -118,6 +118,43 @@ definitions:
        doc: |
          Hardware timestamp comes from one PHY device
          of the network topology
  -
    name: pse-event
    doc: PSE event list for the PSE controller
    type: flags
    name-prefix: ethtool-
    entries:
      -
        name: pse-event-over-current
        doc: PSE output current is too high
      -
        name: pse-event-over-temp
        doc: PSE in over temperature state
      -
        name: c33-pse-event-detection
        doc: |
          detection process occur on the PSE. IEEE 802.3-2022 33.2.5 and
          145.2.6 PSE detection of PDs. IEEE 802.3-202 30.9.1.1.5
          aPSEPowerDetectionStatus
      -
        name: c33-pse-event-classification
        doc: |
          classification process occur on the PSE. IEEE 802.3-2022 33.2.6
          and 145.2.8 classification of PDs mutual identification.
          IEEE 802.3-2022 30.9.1.1.8 aPSEPowerClassification.
      -
        name: c33-pse-event-disconnection
        doc: |
          PD has been disconnected on the PSE. IEEE 802.3-2022 33.3.8
          and 145.3.9 PD Maintain Power Signature. IEEE 802.3-2022
          33.5.1.2.9 MPS Absent. IEEE 802.3-2022 30.9.1.1.20
          aPSEMPSAbsentCounter.
      -
        name: pse-event-over-budget
        doc: PSE turned off due to over budget situation
      -
        name: pse-event-sw-pw-control-error
        doc: PSE faced an error managing the power control from software

attribute-sets:
  -
@@ -1395,6 +1432,18 @@ attribute-sets:
        type: nest
        multi-attr: true
        nested-attributes: c33-pse-pw-limit
      -
        name: pse-pw-d-id
        type: u32
        name-prefix: ethtool-a-
      -
        name: pse-prio-max
        type: u32
        name-prefix: ethtool-a-
      -
        name: pse-prio
        type: u32
        name-prefix: ethtool-a-
  -
    name: rss
    attr-cnt-name: __ethtool-a-rss-cnt
@@ -1555,6 +1604,19 @@ attribute-sets:
        name: hwtstamp-flags
        type: nest
        nested-attributes: bitset
  -
    name: pse-ntf
    attr-cnt-name: --ethtool-a-pse-ntf-cnt
    attributes:
      -
        name: header
        type: nest
        nested-attributes: header
      -
        name: events
        type: uint
        enum: pse-event
        doc: List of events reported by the PSE controller

operations:
  enum-model: directional
@@ -2205,6 +2267,9 @@ operations:
            - c33-pse-ext-substate
            - c33-pse-avail-pw-limit
            - c33-pse-pw-limit-ranges
            - pse-pw-d-id
            - pse-prio-max
            - pse-prio
      dump: *pse-get-op
    -
      name: pse-set
@@ -2219,6 +2284,7 @@ operations:
            - podl-pse-admin-control
            - c33-pse-admin-control
            - c33-pse-avail-pw-limit
            - pse-prio
    -
      name: rss-get
      doc: Get RSS params.
@@ -2413,3 +2479,13 @@ operations:
          attributes: *tsconfig
        reply:
          attributes: *tsconfig
    -
      name: pse-ntf
      doc: Notification for PSE events.

      attribute-set: pse-ntf

      event:
        attributes:
          - header
          - events
+49 −0
Original line number Diff line number Diff line
@@ -290,6 +290,7 @@ Kernel to userspace:
  ``ETHTOOL_MSG_PHY_NTF``                  Ethernet PHY information change
  ``ETHTOOL_MSG_TSCONFIG_GET_REPLY``       hw timestamping configuration
  ``ETHTOOL_MSG_TSCONFIG_SET_REPLY``       new hw timestamping configuration
  ``ETHTOOL_MSG_PSE_NTF``                  PSE events notification
  ======================================== =================================

``GET`` requests are sent by userspace applications to retrieve device
@@ -1788,6 +1789,11 @@ Kernel response contents:
                                                      limit of the PoE PSE.
  ``ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES``       nested  Supported power limit
                                                      configuration ranges.
  ``ETHTOOL_A_PSE_PW_D_ID``                      u32  Index of the PSE power domain
  ``ETHTOOL_A_PSE_PRIO_MAX``                     u32  Priority maximum configurable
                                                      on the PoE PSE
  ``ETHTOOL_A_PSE_PRIO``                         u32  Priority of the PoE PSE
                                                      currently configured
  ==========================================  ======  =============================

When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` attribute identifies
@@ -1861,6 +1867,15 @@ identifies the C33 PSE power limit ranges through
If the controller works with fixed classes, the min and max values will be
equal.

The ``ETHTOOL_A_PSE_PW_D_ID`` attribute identifies the index of PSE power
domain.

When set, the optional ``ETHTOOL_A_PSE_PRIO_MAX`` attribute identifies
the PSE maximum priority value.
When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
identifies the currently configured PSE priority.
For a description of PSE priority attributes, see ``PSE_SET``.

PSE_SET
=======

@@ -1874,6 +1889,8 @@ Request contents:
  ``ETHTOOL_A_C33_PSE_ADMIN_CONTROL``        u32  Control PSE Admin state
  ``ETHTOOL_A_C33_PSE_AVAIL_PWR_LIMIT``      u32  Control PoE PSE available
                                                  power limit
  ``ETHTOOL_A_PSE_PRIO``                     u32  Control priority of the
                                                  PoE PSE
  ======================================  ======  =============================

When set, the optional ``ETHTOOL_A_PODL_PSE_ADMIN_CONTROL`` attribute is used
@@ -1896,6 +1913,38 @@ various existing products that document power consumption in watts rather than
classes. If power limit configuration based on classes is needed, the
conversion can be done in user space, for example by ethtool.

When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
control the PSE priority. Allowed priority value are between zero and
the value of ``ETHTOOL_A_PSE_PRIO_MAX`` attribute.

A lower value indicates a higher priority, meaning that a priority value
of 0 corresponds to the highest port priority.
Port priority serves two functions:

 - Power-up Order: After a reset, ports are powered up in order of their
   priority from highest to lowest. Ports with higher priority
   (lower values) power up first.
 - Shutdown Order: When the power budget is exceeded, ports with lower
   priority (higher values) are turned off first.

PSE_NTF
=======

Notify PSE events.

Notification contents:

  ===============================  ======  ========================
  ``ETHTOOL_A_PSE_HEADER``         nested  request header
  ``ETHTOOL_A_PSE_EVENTS``         bitset  PSE events
  ===============================  ======  ========================

When set, the optional ``ETHTOOL_A_PSE_EVENTS`` attribute identifies the
PSE events.

.. kernel-doc:: include/uapi/linux/ethtool_netlink_generated.h
    :identifiers: ethtool_pse_event

RSS_GET
=======

+14 −12
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("FWNODE MDIO bus (Ethernet PHY) accessors");

static struct pse_control *
fwnode_find_pse_control(struct fwnode_handle *fwnode)
fwnode_find_pse_control(struct fwnode_handle *fwnode,
			struct phy_device *phydev)
{
	struct pse_control *psec;
	struct device_node *np;
@@ -30,7 +31,7 @@ fwnode_find_pse_control(struct fwnode_handle *fwnode)
	if (!np)
		return NULL;

	psec = of_pse_control_get(np);
	psec = of_pse_control_get(np, phydev);
	if (PTR_ERR(psec) == -ENOENT)
		return NULL;

@@ -128,15 +129,9 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
	u32 phy_id;
	int rc;

	psec = fwnode_find_pse_control(child);
	if (IS_ERR(psec))
		return PTR_ERR(psec);

	mii_ts = fwnode_find_mii_timestamper(child);
	if (IS_ERR(mii_ts)) {
		rc = PTR_ERR(mii_ts);
		goto clean_pse;
	}
	if (IS_ERR(mii_ts))
		return PTR_ERR(mii_ts);

	is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45");
	if (is_c45 || fwnode_get_phy_id(child, &phy_id))
@@ -169,6 +164,12 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
			goto clean_phy;
	}

	psec = fwnode_find_pse_control(child, phy);
	if (IS_ERR(psec)) {
		rc = PTR_ERR(psec);
		goto unregister_phy;
	}

	phy->psec = psec;

	/* phy->mii_ts may already be defined by the PHY driver. A
@@ -180,12 +181,13 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,

	return 0;

unregister_phy:
	if (is_acpi_node(child) || is_of_node(child))
		phy_device_remove(phy);
clean_phy:
	phy_device_free(phy);
clean_mii_ts:
	unregister_mii_timestamper(mii_ts);
clean_pse:
	pse_control_put(psec);

	return rc;
}
Loading