From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew@lunn.ch>, Michal Kubecek <mkubecek@suse.cz>,
Dent Project <dentproject@linuxfoundation.org>,
Kyle Swenson <kyle.swenson@est.tech>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH ethtool v2 3/3] ethtool: pse-pd: Add PSE event monitoring support
Date: Wed, 13 Aug 2025 14:44:27 +0200 [thread overview]
Message-ID: <aJyIqz4T1MWuI-p9@pengutronix.de> (raw)
In-Reply-To: <20250813-b4-feature_poe_pw_budget-v2-3-0bef6bfcc708@bootlin.com>
On Wed, Aug 13, 2025 at 10:57:52AM +0200, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
....
> diff --git a/netlink/pse-pd.c b/netlink/pse-pd.c
> index 5bde176..3fb0616 100644
> --- a/netlink/pse-pd.c
> +++ b/netlink/pse-pd.c
> @@ -475,6 +475,64 @@ int nl_gpse(struct cmd_context *ctx)
> return ret;
> }
>
> +static const char *pse_events_name(u64 val)
> +{
> + switch (val) {
> + case ETHTOOL_PSE_EVENT_OVER_CURRENT:
> + return "over-current";
> + case ETHTOOL_PSE_EVENT_OVER_TEMP:
> + return "over-temperature";
> + case ETHTOOL_C33_PSE_EVENT_DETECTION:
> + return "detection";
> + case ETHTOOL_C33_PSE_EVENT_CLASSIFICATION:
> + return "classification";
> + case ETHTOOL_C33_PSE_EVENT_DISCONNECTION:
> + return "disconnection";
> + case ETHTOOL_PSE_EVENT_OVER_BUDGET:
> + return "over-budget";
> + case ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR:
> + return "software power control error";
> + default:
> + return "unknown";
> + }
> +}
> +
> +int pse_ntf_cb(const struct nlmsghdr *nlhdr, void *data)
> +{
> + const struct nlattr *tb[ETHTOOL_A_PSE_MAX + 1] = {};
s/ETHTOOL_A_PSE_MAX/ETHTOOL_A_PSE_NTF_MAX ?
> + struct nl_context *nlctx = data;
> + DECLARE_ATTR_TB_INFO(tb);
> + u64 val;
> + int ret, i;
> +
> + ret = mnl_attr_parse(nlhdr, GENL_HDRLEN, attr_cb, &tb_info);
> + if (ret < 0)
> + return MNL_CB_OK;
> +
> + if (!tb[ETHTOOL_A_PSE_NTF_EVENTS])
> + return MNL_CB_OK;
> +
> + nlctx->devname = get_dev_name(tb[ETHTOOL_A_PSE_HEADER]);
s/ETHTOOL_A_PSE_HEADER/ETHTOOL_A_PSE_NTF_HEADER ?
> + if (!dev_ok(nlctx))
> + return MNL_CB_OK;
> +
> + open_json_object(NULL);
> + print_string(PRINT_ANY, "ifname", "PSE event for %s:\n",
> + nlctx->devname);
> + open_json_array("events", "Events:");
> + val = attr_get_uint(tb[ETHTOOL_A_PSE_NTF_EVENTS]);
we have here uint but val is u64, is it as expected?
> + for (i = 0; 1 << i <= ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR; i++)
> + if (val & 1 << i)
> + print_string(PRINT_ANY, NULL, " %s",
> + pse_events_name(val & 1 << i));
Hm, may be it is better to not limit to ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR
and report unknow numeric value. It will keep even old ethtool at least
partially usable.
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-08-13 12:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 8:57 [PATCH ethtool v2 0/3] Add support for PSE priority feature and PSE event monitoring Kory Maincent
2025-08-13 8:57 ` [PATCH ethtool v2 1/3] update UAPI header copies Kory Maincent
2025-08-13 8:57 ` [PATCH ethtool v2 2/3] ethtool: pse-pd: Add PSE priority support Kory Maincent
2025-08-13 12:25 ` Oleksij Rempel
2025-08-13 12:57 ` Kory Maincent
2025-08-13 8:57 ` [PATCH ethtool v2 3/3] ethtool: pse-pd: Add PSE event monitoring support Kory Maincent
2025-08-13 12:44 ` Oleksij Rempel [this message]
2025-08-13 13:22 ` Kory Maincent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJyIqz4T1MWuI-p9@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dentproject@linuxfoundation.org \
--cc=edumazet@google.com \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=kyle.swenson@est.tech \
--cc=linux-kernel@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®