Re: [PATCH ethtool v2 3/3] ethtool: pse-pd: Add PSE event monitoring support
From: Kory Maincent
Date: Wed Aug 13 2025 - 09:25:49 EST
Le Wed, 13 Aug 2025 14:44:27 +0200,
Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> a écrit :
> > +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 ?
Thanks, well spotted.
> > + 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 ?
Thanks, well spotted.
> > + 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?
Yes, same behavior in Linux using nla_put_uint().
> > + 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.
Ok, I will loop until UINT_MAX then.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com