[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250417144349.5b30afec@fedora.home>
Date: Thu, 17 Apr 2025 14:43:49 +0200
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: Kory Maincent <kory.maincent@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>, 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>, Jonathan Corbet <corbet@....net>, Donald Hunter
<donald.hunter@...il.com>, Rob Herring <robh@...nel.org>, Andrew Lunn
<andrew+netdev@...n.ch>, Simon Horman <horms@...nel.org>, Heiner Kallweit
<hkallweit1@...il.com>, Russell King <linux@...linux.org.uk>, Krzysztof
Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Liam
Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>, Thomas
Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>, Dent
Project <dentproject@...uxfoundation.org>, kernel@...gutronix.de,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v8 02/13] net: pse-pd: Add support for
reporting events
Hi Köry,
On Wed, 16 Apr 2025 15:44:17 +0200
Kory Maincent <kory.maincent@...tlin.com> wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
>
> Add support for devm_pse_irq_helper() to register PSE interrupts and report
> events such as over-current or over-temperature conditions. This follows a
> similar approach to the regulator API but also sends notifications using a
> dedicated PSE ethtool netlink socket.
>
> Introduce an attached_phydev field in the pse_control structure to store
> the phydev attached to the PSE PI, ensuring that PSE ethtool notifications
> are sent to the correct network interface.
>
> The attached_phydev pointer is directly tied to the PHY lifecycle. It
> is set when the PHY is registered and cleared when the PHY is removed.
> There is no need to use a refcount, as doing so could interfere with
> the PHY removal process.
>
> Signed-off-by: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
> Reviewed-by: Oleksij Rempel <o.rempel@...gutronix.de>
> ---
[...]
> +void ethnl_pse_send_ntf(struct phy_device *phydev, unsigned long notifs,
> + struct netlink_ext_ack *extack)
> +{
> + struct net_device *netdev = phydev->attached_dev;
> + struct genl_info info;
> + void *reply_payload;
> + struct sk_buff *skb;
> + int reply_len;
> + int ret;
> +
> + if (!netdev || !notifs)
> + return;
> +
> + ethnl_info_init_ntf(&info, ETHTOOL_MSG_PSE_NTF);
> + info.extack = extack;
> +
> + reply_len = ethnl_reply_header_size() +
> + nla_total_size(sizeof(u32)); /* _PSE_NTF_EVENTS */
> +
> + skb = genlmsg_new(reply_len, GFP_KERNEL);
I think you need to check skb here before using it.
> + reply_payload = ethnl_bcastmsg_put(skb, ETHTOOL_MSG_PSE_NTF);
> + if (!reply_payload)
> + goto err_skb;
> +
> + ret = ethnl_fill_reply_header(skb, netdev,
> + ETHTOOL_A_PSE_NTF_HEADER);
> + if (ret < 0)
> + goto err_skb;
> +
> + if (nla_put_u32(skb, ETHTOOL_A_PSE_NTF_EVENTS, notifs))
> + goto err_skb;
> +
> + genlmsg_end(skb, reply_payload);
> + ethnl_multicast(skb, netdev);
> + return;
> +
> +err_skb:
> + nlmsg_free(skb);
> +}
> +EXPORT_SYMBOL_GPL(ethnl_pse_send_ntf);
>
Maxime
Powered by blists - more mailing lists