[PATCH ethtool-next 2/2] ethtool: pse-pd: Add support for Power over Ethernet (clause 33)
From: Kory Maincent
Date: Tue Apr 23 2024 - 05:06:42 EST
From: Kory Maincent (Dent Project) <kory.maincent@xxxxxxxxxxx>
This update extends PSE support to include Power over Ethernet (clause 33),
encompassing standards 802.3af, 802.3at, and 802.3bt infrastructure.
Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>
---
ethtool.c | 1 +
netlink/pse-pd.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/ethtool.c b/ethtool.c
index e587597..d85a57a 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6216,6 +6216,7 @@ static const struct option args[] = {
.nlfunc = nl_spse,
.help = "Set Power Sourcing Equipment settings",
.xhelp = " [ podl-pse-admin-control enable|disable ]\n"
+ " [ c33-pse-admin-control enable|disable ]\n"
},
{
.opts = "-h|--help",
diff --git a/netlink/pse-pd.c b/netlink/pse-pd.c
index d6faff8..2c8dd89 100644
--- a/netlink/pse-pd.c
+++ b/netlink/pse-pd.c
@@ -54,6 +54,41 @@ static const char *podl_pse_pw_d_status_name(u32 val)
}
}
+static const char *c33_pse_admin_state_name(u32 val)
+{
+ switch (val) {
+ case ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN:
+ return "unknown";
+ case ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED:
+ return "disabled";
+ case ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED:
+ return "enabled";
+ default:
+ return "unsupported";
+ }
+}
+
+static const char *c33_pse_pw_d_status_name(u32 val)
+{
+ switch (val) {
+ case ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN:
+ return "unknown";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED:
+ return "disabled";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING:
+ return "searching";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING:
+ return "delivering power";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_TEST:
+ return "test";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_FAULT:
+ return "fault";
+ case ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT:
+ return "otherfault";
+ default:
+ return "unsupported";
+ }
+}
int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data)
{
const struct nlattr *tb[ETHTOOL_A_PSE_MAX + 1] = {};
@@ -98,6 +133,24 @@ int pse_reply_cb(const struct nlmsghdr *nlhdr, void *data)
podl_pse_pw_d_status_name(val));
}
+ if (tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_STATE]);
+ print_string(PRINT_ANY, "c33-pse-admin-state",
+ "Clause 33 PSE Admin State: %s\n",
+ c33_pse_admin_state_name(val));
+ }
+
+ if (tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]) {
+ u32 val;
+
+ val = mnl_attr_get_u32(tb[ETHTOOL_A_C33_PSE_PW_D_STATUS]);
+ print_string(PRINT_ANY, "c33-pse-power-detection-status",
+ "Clause 33 PSE Power Detection Status: %s\n",
+ c33_pse_pw_d_status_name(val));
+ }
+
close_json_object();
return MNL_CB_OK;
@@ -138,6 +191,12 @@ static const struct lookup_entry_u32 podl_pse_admin_control_values[] = {
{}
};
+static const struct lookup_entry_u32 c33_pse_admin_control_values[] = {
+ { .arg = "enable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED },
+ { .arg = "disable", .val = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED },
+ {}
+};
+
static const struct param_parser spse_params[] = {
{
.arg = "podl-pse-admin-control",
@@ -146,6 +205,13 @@ static const struct param_parser spse_params[] = {
.handler_data = podl_pse_admin_control_values,
.min_argc = 1,
},
+ {
+ .arg = "c33-pse-admin-control",
+ .type = ETHTOOL_A_C33_PSE_ADMIN_CONTROL,
+ .handler = nl_parse_lookup_u32,
+ .handler_data = c33_pse_admin_control_values,
+ .min_argc = 1,
+ },
{}
};
--
2.34.1