Skip to content

Commit 757639a

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a5b4e4f + 82566eb commit 757639a

File tree

12 files changed

+2038
-54
lines changed

12 files changed

+2038
-54
lines changed

Documentation/devicetree/bindings/net/pse-pd/microchip,pd692x0.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ properties:
2222
reg:
2323
maxItems: 1
2424

25+
vdd-supply:
26+
description: Regulator that provides 3.3V VDD power supply.
27+
28+
vdda-supply:
29+
description: Regulator that provides 3.3V VDDA power supply.
30+
2531
managers:
2632
type: object
2733
additionalProperties: false
@@ -68,6 +74,15 @@ properties:
6874
"#size-cells":
6975
const: 0
7076

77+
vmain-supply:
78+
description: Regulator that provides 44-57V VMAIN power supply.
79+
80+
vaux5-supply:
81+
description: Regulator that provides 5V VAUX5 power supply.
82+
83+
vaux3p3-supply:
84+
description: Regulator that provides 3.3V VAUX3P3 power supply.
85+
7186
patternProperties:
7287
'^port@[0-7]$':
7388
type: object
@@ -106,10 +121,11 @@ examples:
106121
#address-cells = <1>;
107122
#size-cells = <0>;
108123
109-
manager@0 {
124+
manager0: manager@0 {
110125
reg = <0>;
111126
#address-cells = <1>;
112127
#size-cells = <0>;
128+
vmain-supply = <&pse1_supply>;
113129
114130
phys0: port@0 {
115131
reg = <0>;
@@ -161,15 +177,15 @@ examples:
161177
pairset-names = "alternative-a", "alternative-b";
162178
pairsets = <&phys0>, <&phys1>;
163179
polarity-supported = "MDI", "S";
164-
vpwr-supply = <&vpwr1>;
180+
vpwr-supply = <&manager0>;
165181
};
166182
pse_pi1: pse-pi@1 {
167183
reg = <1>;
168184
#pse-cells = <0>;
169185
pairset-names = "alternative-a";
170186
pairsets = <&phys2>;
171187
polarity-supported = "MDI";
172-
vpwr-supply = <&vpwr2>;
188+
vpwr-supply = <&manager0>;
173189
};
174190
};
175191
};

Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ properties:
2020
reg:
2121
maxItems: 1
2222

23+
interrupts:
24+
maxItems: 1
25+
2326
'#pse-cells':
2427
const: 1
2528

@@ -62,16 +65,21 @@ unevaluatedProperties: false
6265
required:
6366
- compatible
6467
- reg
68+
- interrupts
6569

6670
examples:
6771
- |
72+
#include <dt-bindings/interrupt-controller/irq.h>
73+
6874
i2c {
6975
#address-cells = <1>;
7076
#size-cells = <0>;
7177
7278
ethernet-pse@20 {
7379
compatible = "ti,tps23881";
7480
reg = <0x20>;
81+
interrupts = <8 IRQ_TYPE_LEVEL_HIGH>;
82+
interrupt-parent = <&gpiog>;
7583
7684
channels {
7785
#address-cells = <1>;

Documentation/netlink/specs/ethtool.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,43 @@ definitions:
118118
doc: |
119119
Hardware timestamp comes from one PHY device
120120
of the network topology
121+
-
122+
name: pse-event
123+
doc: PSE event list for the PSE controller
124+
type: flags
125+
name-prefix: ethtool-
126+
entries:
127+
-
128+
name: pse-event-over-current
129+
doc: PSE output current is too high
130+
-
131+
name: pse-event-over-temp
132+
doc: PSE in over temperature state
133+
-
134+
name: c33-pse-event-detection
135+
doc: |
136+
detection process occur on the PSE. IEEE 802.3-2022 33.2.5 and
137+
145.2.6 PSE detection of PDs. IEEE 802.3-202 30.9.1.1.5
138+
aPSEPowerDetectionStatus
139+
-
140+
name: c33-pse-event-classification
141+
doc: |
142+
classification process occur on the PSE. IEEE 802.3-2022 33.2.6
143+
and 145.2.8 classification of PDs mutual identification.
144+
IEEE 802.3-2022 30.9.1.1.8 aPSEPowerClassification.
145+
-
146+
name: c33-pse-event-disconnection
147+
doc: |
148+
PD has been disconnected on the PSE. IEEE 802.3-2022 33.3.8
149+
and 145.3.9 PD Maintain Power Signature. IEEE 802.3-2022
150+
33.5.1.2.9 MPS Absent. IEEE 802.3-2022 30.9.1.1.20
151+
aPSEMPSAbsentCounter.
152+
-
153+
name: pse-event-over-budget
154+
doc: PSE turned off due to over budget situation
155+
-
156+
name: pse-event-sw-pw-control-error
157+
doc: PSE faced an error managing the power control from software
121158

122159
attribute-sets:
123160
-
@@ -1395,6 +1432,18 @@ attribute-sets:
13951432
type: nest
13961433
multi-attr: true
13971434
nested-attributes: c33-pse-pw-limit
1435+
-
1436+
name: pse-pw-d-id
1437+
type: u32
1438+
name-prefix: ethtool-a-
1439+
-
1440+
name: pse-prio-max
1441+
type: u32
1442+
name-prefix: ethtool-a-
1443+
-
1444+
name: pse-prio
1445+
type: u32
1446+
name-prefix: ethtool-a-
13981447
-
13991448
name: rss
14001449
attr-cnt-name: __ethtool-a-rss-cnt
@@ -1555,6 +1604,19 @@ attribute-sets:
15551604
name: hwtstamp-flags
15561605
type: nest
15571606
nested-attributes: bitset
1607+
-
1608+
name: pse-ntf
1609+
attr-cnt-name: --ethtool-a-pse-ntf-cnt
1610+
attributes:
1611+
-
1612+
name: header
1613+
type: nest
1614+
nested-attributes: header
1615+
-
1616+
name: events
1617+
type: uint
1618+
enum: pse-event
1619+
doc: List of events reported by the PSE controller
15581620

15591621
operations:
15601622
enum-model: directional
@@ -2205,6 +2267,9 @@ operations:
22052267
- c33-pse-ext-substate
22062268
- c33-pse-avail-pw-limit
22072269
- c33-pse-pw-limit-ranges
2270+
- pse-pw-d-id
2271+
- pse-prio-max
2272+
- pse-prio
22082273
dump: *pse-get-op
22092274
-
22102275
name: pse-set
@@ -2219,6 +2284,7 @@ operations:
22192284
- podl-pse-admin-control
22202285
- c33-pse-admin-control
22212286
- c33-pse-avail-pw-limit
2287+
- pse-prio
22222288
-
22232289
name: rss-get
22242290
doc: Get RSS params.
@@ -2413,3 +2479,13 @@ operations:
24132479
attributes: *tsconfig
24142480
reply:
24152481
attributes: *tsconfig
2482+
-
2483+
name: pse-ntf
2484+
doc: Notification for PSE events.
2485+
2486+
attribute-set: pse-ntf
2487+
2488+
event:
2489+
attributes:
2490+
- header
2491+
- events

Documentation/networking/ethtool-netlink.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ Kernel to userspace:
290290
``ETHTOOL_MSG_PHY_NTF`` Ethernet PHY information change
291291
``ETHTOOL_MSG_TSCONFIG_GET_REPLY`` hw timestamping configuration
292292
``ETHTOOL_MSG_TSCONFIG_SET_REPLY`` new hw timestamping configuration
293+
``ETHTOOL_MSG_PSE_NTF`` PSE events notification
293294
======================================== =================================
294295

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

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

1870+
The ``ETHTOOL_A_PSE_PW_D_ID`` attribute identifies the index of PSE power
1871+
domain.
1872+
1873+
When set, the optional ``ETHTOOL_A_PSE_PRIO_MAX`` attribute identifies
1874+
the PSE maximum priority value.
1875+
When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
1876+
identifies the currently configured PSE priority.
1877+
For a description of PSE priority attributes, see ``PSE_SET``.
1878+
18641879
PSE_SET
18651880
=======
18661881

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

18791896
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
18961913
classes. If power limit configuration based on classes is needed, the
18971914
conversion can be done in user space, for example by ethtool.
18981915

1916+
When set, the optional ``ETHTOOL_A_PSE_PRIO`` attributes is used to
1917+
control the PSE priority. Allowed priority value are between zero and
1918+
the value of ``ETHTOOL_A_PSE_PRIO_MAX`` attribute.
1919+
1920+
A lower value indicates a higher priority, meaning that a priority value
1921+
of 0 corresponds to the highest port priority.
1922+
Port priority serves two functions:
1923+
1924+
- Power-up Order: After a reset, ports are powered up in order of their
1925+
priority from highest to lowest. Ports with higher priority
1926+
(lower values) power up first.
1927+
- Shutdown Order: When the power budget is exceeded, ports with lower
1928+
priority (higher values) are turned off first.
1929+
1930+
PSE_NTF
1931+
=======
1932+
1933+
Notify PSE events.
1934+
1935+
Notification contents:
1936+
1937+
=============================== ====== ========================
1938+
``ETHTOOL_A_PSE_HEADER`` nested request header
1939+
``ETHTOOL_A_PSE_EVENTS`` bitset PSE events
1940+
=============================== ====== ========================
1941+
1942+
When set, the optional ``ETHTOOL_A_PSE_EVENTS`` attribute identifies the
1943+
PSE events.
1944+
1945+
.. kernel-doc:: include/uapi/linux/ethtool_netlink_generated.h
1946+
:identifiers: ethtool_pse_event
1947+
18991948
RSS_GET
19001949
=======
19011950

drivers/net/mdio/fwnode_mdio.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ MODULE_LICENSE("GPL");
1818
MODULE_DESCRIPTION("FWNODE MDIO bus (Ethernet PHY) accessors");
1919

2020
static struct pse_control *
21-
fwnode_find_pse_control(struct fwnode_handle *fwnode)
21+
fwnode_find_pse_control(struct fwnode_handle *fwnode,
22+
struct phy_device *phydev)
2223
{
2324
struct pse_control *psec;
2425
struct device_node *np;
@@ -30,7 +31,7 @@ fwnode_find_pse_control(struct fwnode_handle *fwnode)
3031
if (!np)
3132
return NULL;
3233

33-
psec = of_pse_control_get(np);
34+
psec = of_pse_control_get(np, phydev);
3435
if (PTR_ERR(psec) == -ENOENT)
3536
return NULL;
3637

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

131-
psec = fwnode_find_pse_control(child);
132-
if (IS_ERR(psec))
133-
return PTR_ERR(psec);
134-
135132
mii_ts = fwnode_find_mii_timestamper(child);
136-
if (IS_ERR(mii_ts)) {
137-
rc = PTR_ERR(mii_ts);
138-
goto clean_pse;
139-
}
133+
if (IS_ERR(mii_ts))
134+
return PTR_ERR(mii_ts);
140135

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

167+
psec = fwnode_find_pse_control(child, phy);
168+
if (IS_ERR(psec)) {
169+
rc = PTR_ERR(psec);
170+
goto unregister_phy;
171+
}
172+
172173
phy->psec = psec;
173174

174175
/* 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,
180181

181182
return 0;
182183

184+
unregister_phy:
185+
if (is_acpi_node(child) || is_of_node(child))
186+
phy_device_remove(phy);
183187
clean_phy:
184188
phy_device_free(phy);
185189
clean_mii_ts:
186190
unregister_mii_timestamper(mii_ts);
187-
clean_pse:
188-
pse_control_put(psec);
189191

190192
return rc;
191193
}

0 commit comments

Comments
 (0)