netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Jonathan Corbet <corbet@lwn.net>,
	Donald Hunter <donald.hunter@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	Kyle Swenson <kyle.swenson@est.tech>,
	Dent Project <dentproject@linuxfoundation.org>,
	kernel@pengutronix.de,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v10 02/13] net: pse-pd: Add support for reporting events
Date: Thu, 8 May 2025 20:10:41 -0700	[thread overview]
Message-ID: <20250508201041.40566d3f@kernel.org> (raw)
In-Reply-To: <20250506-feature_poe_port_prio-v10-2-55679a4895f9@bootlin.com>

On Tue, 06 May 2025 11:38:34 +0200 Kory Maincent wrote:
> diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml
> index c650cd3dcb80..fbfd293987c1 100644
> --- a/Documentation/netlink/specs/ethtool.yaml
> +++ b/Documentation/netlink/specs/ethtool.yaml
> @@ -98,6 +98,12 @@ definitions:
>      name: tcp-data-split
>      type: enum
>      entries: [ unknown, disabled, enabled ]
> +  -
> +    name: pse-events
> +    type: flags
> +    name-prefix: ethtool-pse-event-
> +    header: linux/ethtool.h
> +    entries: [ over-current, over-temp ]

please change this enum similarly to what I suggested on the hwts
source patch

>  attribute-sets:
>    -
> @@ -1528,6 +1534,18 @@ attribute-sets:
>          name: hwtstamp-flags
>          type: nest
>          nested-attributes: bitset
> +  -
> +    name: pse-ntf
> +    attr-cnt-name: __ethtool-a-pse-ntf-cnt

please use -- instead of underscores

> +    attributes:
> +      -
> +        name: header
> +        type: nest
> +        nested-attributes: header
> +      -
> +        name: events
> +        type: uint
> +        enum: pse-events

A tiny "doc:" here or better explanation in the Documentation/ 
may be nice. I thought it was a counter when I first looked...


> +  ===============================  ======  ========================
> +  ``ETHTOOL_A_PSE_HEADER``         nested  request header
> +  ``ETHTOOL_A_PSE_EVENTS``         bitset  PSE events
> +  ===============================  ======  ========================
> +
> +When set, the optional ``ETHTOOL_A_PSE_EVENTS`` attribute identifies the
> +PSE events.
> +
> +.. kernel-doc:: include/uapi/linux/ethtool.h
> +    :identifiers: ethtool_pse_events

I guess in HTML the enum will get rendered here so it will be clearer.

>  static DEFINE_MUTEX(pse_list_mutex);
>  static LIST_HEAD(pse_controller_list);
> @@ -23,6 +27,7 @@ static LIST_HEAD(pse_controller_list);
>   * @list: list entry for the pcdev's PSE controller list
>   * @id: ID of the PSE line in the PSE controller device
>   * @refcnt: Number of gets of this pse_control
> + * @attached_phydev: PHY device pointer attached by the PSE control
>   */
>  struct pse_control {
>  	struct pse_controller_dev *pcdev;
> @@ -30,6 +35,7 @@ struct pse_control {
>  	struct list_head list;
>  	unsigned int id;
>  	struct kref refcnt;
> +	struct phy_device *attached_phydev;
>  };

Adding the attached_phydev should be a separate patch, I think

>  static int of_load_single_pse_pi_pairset(struct device_node *node,
> @@ -208,6 +214,52 @@ static int of_load_pse_pis(struct pse_controller_dev *pcdev)
>  	return ret;
>  }
>  
> +/**
> + * pse_control_find_net_by_id - Find net attached to the pse control id
> + * @pcdev: a pointer to the PSE
> + * @id: index of the PSE control
> + * @tracker: refcount tracker used by netdev
> + *
> + * Return: net device pointer or NULL. The device returned has had a
> + *	   reference added and the pointer is safe until the user calls
> + *	   netdev_put() to indicate they have finished with it.
> + */
> +static struct net_device *
> +pse_control_find_net_by_id(struct pse_controller_dev *pcdev, int id,
> +			   netdevice_tracker *tracker)
> +{
> +	struct pse_control *psec, *next;
> +
> +	mutex_lock(&pse_list_mutex);
> +	list_for_each_entry_safe(psec, next, &pcdev->pse_control_head, list) {
> +		if (psec->id == id) {
> +			struct net_device *netdev = NULL;
> +			struct phy_device *phydev;
> +
> +			kref_get(&psec->refcnt);
> +			/* Release the mutex before taking the rtnl lock
> +			 * to avoid deadlock in case of a pse_control_put
> +			 * call with the rtnl lock held.
> +			 */
> +			mutex_unlock(&pse_list_mutex);
> +			/* Acquire rtnl to protect the net device
> +			 * reference get.
> +			 */
> +			rtnl_lock();
> +			phydev = psec->attached_phydev;
> +			if (phydev->attached_dev) {
> +				netdev = phydev->attached_dev;
> +				netdev_hold(netdev, tracker, GFP_ATOMIC);

GFP_KERNEL ?

> +			}
> +			rtnl_unlock();
> +			pse_control_put(psec);
> +			return netdev;
> +		}
> +	}
> +	mutex_unlock(&pse_list_mutex);
> +	return NULL;
> +}
> +
>  static int pse_pi_is_enabled(struct regulator_dev *rdev)
>  {
>  	struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);

> +/**
> + * devm_pse_irq_helper - Register IRQ based PSE event notifier
> + *

Why the empty line here but not in the other kdocs?

> + * @pcdev: a pointer to the PSE
> + * @irq: the irq value to be passed to request_irq
> + * @irq_flags: the flags to be passed to request_irq
> + * @d: PSE interrupt description
> + *
> + * Return: 0 on success and failure value on error

... and errno on failure ?

> + */

> diff --git a/net/ethtool/pse-pd.c b/net/ethtool/pse-pd.c
> index 4f6b99eab2a6..1234bce46413 100644
> --- a/net/ethtool/pse-pd.c
> +++ b/net/ethtool/pse-pd.c
> @@ -12,6 +12,7 @@
>  #include <linux/ethtool_netlink.h>
>  #include <linux/ethtool.h>
>  #include <linux/phy.h>
> +#include "bitset.h"

Unused include.

>  struct pse_req_info {
>  	struct ethnl_req_info base;
> @@ -315,3 +316,46 @@ const struct ethnl_request_ops ethnl_pse_request_ops = {
>  	.set			= ethnl_set_pse,
>  	/* PSE has no notification */
>  };
> +
> +void ethnl_pse_send_ntf(struct net_device *netdev, unsigned long notifs,
> +			struct netlink_ext_ack *extack)
> +{
> +	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;

You don't seem to be using this info for anything.

> +	reply_len = ethnl_reply_header_size() +
> +		    nla_total_size(sizeof(u32)); /* _PSE_NTF_EVENTS */
> +
> +	skb = genlmsg_new(reply_len, GFP_KERNEL);
> +	if (!skb)
> +		return;
> +
> +	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);

first on a single line

> +	if (ret < 0)
> +		goto err_skb;
> +
> +	if (nla_put_u32(skb, ETHTOOL_A_PSE_NTF_EVENTS, notifs))

put_uint? Or make notifs argument u32, either way is fine, since we only
have 2 bits defined now. The mixing is a bit surprising.

> +		goto err_skb;
> +
> +	genlmsg_end(skb, reply_payload);
> +	ethnl_multicast(skb, netdev);


  reply	other threads:[~2025-05-09  3:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06  9:38 [PATCH net-next v10 00/13] Add support for PSE budget evaluation strategy Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 01/13] net: ethtool: Add support for ethnl_info_init_ntf helper function Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 02/13] net: pse-pd: Add support for reporting events Kory Maincent
2025-05-09  3:10   ` Jakub Kicinski [this message]
2025-05-13  9:44     ` Kory Maincent
2025-05-13 14:41       ` Jakub Kicinski
2025-05-06  9:38 ` [PATCH net-next v10 03/13] net: pse-pd: tps23881: Add support for PSE events and interrupts Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 04/13] net: pse-pd: Add support for PSE power domains Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 05/13] net: ethtool: Add support for new power domains index description Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 06/13] net: pse-pd: Add helper to report hardware enable status of the PI Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 07/13] net: pse-pd: Add support for budget evaluation strategies Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 08/13] net: ethtool: Add PSE port priority support feature Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 09/13] net: pse-pd: pd692x0: Add support for PSE PI priority feature Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 10/13] net: pse-pd: pd692x0: Add support for controller and manager power supplies Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 11/13] dt-bindings: net: pse-pd: microchip,pd692x0: Add manager regulator supply Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 12/13] net: pse-pd: tps23881: Add support for static port priority feature Kory Maincent
2025-05-06  9:38 ` [PATCH net-next v10 13/13] dt-bindings: net: pse-pd: ti,tps23881: Add interrupt description 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=20250508201041.40566d3f@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dentproject@linuxfoundation.org \
    --cc=devicetree@vger.kernel.org \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=kory.maincent@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=kyle.swenson@est.tech \
    --cc=lgirdwood@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).