[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250820-b4-feature_poe_pw_budget-v3-2-c3d57362c086@bootlin.com>
Date: Wed, 20 Aug 2025 11:07:33 +0200
From: Kory Maincent <kory.maincent@...tlin.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Andrew Lunn <andrew@...n.ch>, Michal Kubecek <mkubecek@...e.cz>
Cc: Dent Project <dentproject@...uxfoundation.org>,
Kyle Swenson <kyle.swenson@....tech>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Kory Maincent <kory.maincent@...tlin.com>
Subject: [PATCH ethtool v3 2/3] ethtool: pse-pd: Add PSE priority support
From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
Add support for PSE (Power Sourcing Equipment) priority management:
- Add priority configuration parameter (prio) for port priority management
- Display power domain index, maximum priority, and current priority
Signed-off-by: Kory Maincent <kory.maincent@...tlin.com>
---
Changes in v3:
- Improve doc thanks to Oleksij.
- Add a missing semicolon.
---
ethtool.8.in | 31 +++++++++++++++++++++++++++++++
ethtool.c | 1 +
netlink/pse-pd.c | 29 +++++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/ethtool.8.in b/ethtool.8.in
index 29b8a8c..553592b 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -561,6 +561,7 @@ ethtool \- query or control network driver and hardware settings
.RB [ c33\-pse\-admin\-control
.BR enable | disable ]
.BN c33\-pse\-avail\-pw\-limit N
+.BN prio N
.HP
.B ethtool \-\-flash\-module\-firmware
.I devname
@@ -1911,6 +1912,26 @@ This attribute specifies the allowed power limit ranges in mW for
configuring the c33-pse-avail-pw-limit parameter. It defines the valid
power levels that can be assigned to the c33 PSE in compliance with the
c33 standard.
+.TP
+.B power-domain-index
+Reports the index of the PSE power domain the port belongs to. Every
+port belongs to exactly one power domain. Port priorities are defined
+within that power domain.
+
+Each power domain may have its own maximum budget (e.g., 100 W per
+domain) in addition to a system-wide budget (e.g., 200 W overall).
+Domain limits are enforced first: if a single domain reaches its budget,
+only ports in that domain are affected. The system-wide budget is
+enforced across all domains.
+.TP
+.B priority-max
+Reports the maximum configurable port priority value within the reported
+power domain. The valid range for prio is 0 to priority-max (inclusive).
+.TP
+.B priority
+Reports the currently configured port priority within the reported power
+domain. Lower numeric values indicate higher priority: 0 is the highest
+priority.
.RE
.TP
@@ -1930,6 +1951,16 @@ This parameter manages c33 PSE Admin operations in accordance with the IEEE
This parameter manages c33 PSE Available Power Limit in mW, in accordance
with the IEEE 802.3-2022 33.2.4.4 Variables (pse_available_power)
specification.
+.TP
+.B prio \ N
+Set the port priority, scoped to the port's power domain
+as reported by power-domain-index. Lower values indicate higher
+priority; 0 is the highest. The valid range is 0 to the
+priority-max reported by --show-pse.
+
+When a single domain exceeds its budget, ports in that domain are
+powered up/down by priority (highest first for power-up; lowest shed
+first).
.RE
.TP
diff --git a/ethtool.c b/ethtool.c
index 215f566..948d551 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6339,6 +6339,7 @@ static const struct option args[] = {
.xhelp = " [ podl-pse-admin-control enable|disable ]\n"
" [ c33-pse-admin-control enable|disable ]\n"
" [ c33-pse-avail-pw-limit N ]\n"
+ " [ prio N ]\n"
},
{
.opts = "--flash-module-firmware",
diff --git a/netlink/pse-pd.c b/netlink/pse-pd.c
index fd1fc4d..f761871 100644
--- a/netlink/pse-pd.c
+++ b/netlink/pse-pd.c
@@ -420,6 +420,29 @@ int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data)
}
}
+ if (tb[ETHTOOL_A_PSE_PW_D_ID]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_PSE_PW_D_ID]);
+ print_uint(PRINT_ANY, "power-domain-index",
+ "Power domain index: %u\n", val);
+ }
+
+ if (tb[ETHTOOL_A_PSE_PRIO_MAX]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_PSE_PRIO_MAX]);
+ print_uint(PRINT_ANY, "priority-max",
+ "Max allowed priority: %u\n", val);
+ }
+
+ if (tb[ETHTOOL_A_PSE_PRIO]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_PSE_PRIO]);
+ print_uint(PRINT_ANY, "priority", "Priority: %u\n", val);
+ }
+
close_json_object();
return MNL_CB_OK;
@@ -487,6 +510,12 @@ static const struct param_parser spse_params[] = {
.handler = nl_parse_direct_u32,
.min_argc = 1,
},
+ {
+ .arg = "prio",
+ .type = ETHTOOL_A_PSE_PRIO,
+ .handler = nl_parse_direct_u32,
+ .min_argc = 1,
+ },
{}
};
--
2.43.0
Powered by blists - more mailing lists