2024-02-20 18:44:44

by Maxime Chevallier

[permalink] [raw]
Subject: [PATCH net-next v8 08/13] netlink: specs: add ethnl PHY_GET command set

The PHY_GET command, supporting both DUMP and GET operations, is used to
retrieve the list of PHYs connected to a netdevice, and get topology
information to know where exactly it sits on the physical link.

Add the netlink specs corresponding to that command.

Signed-off-by: Maxime Chevallier <[email protected]>
---
V8: No changes
V7: No changes
V6: Updated the spec according to the new attributes
V5: No changes
V4: Remove the ethtool-user generated code
V3: New patch

Documentation/netlink/specs/ethtool.yaml | 59 ++++++++++++++++++++++++
1 file changed, 59 insertions(+)

diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml
index bb6e1dc6d1c5..e98d78fbc2f3 100644
--- a/Documentation/netlink/specs/ethtool.yaml
+++ b/Documentation/netlink/specs/ethtool.yaml
@@ -16,6 +16,11 @@ definitions:
name: stringset
type: enum
entries: []
+ -
+ name: phy-upstream-type
+ enum-name:
+ type: enum
+ entries: [ mac, phy ]

attribute-sets:
-
@@ -945,6 +950,38 @@ attribute-sets:
-
name: burst-tmr
type: u32
+ -
+ name: phy
+ attributes:
+ -
+ name: header
+ type: nest
+ nested-attributes: header
+ -
+ name: index
+ type: u32
+ -
+ name: drvname
+ type: string
+ -
+ name: name
+ type: string
+ -
+ name: upstream-type
+ type: u32
+ enum: phy-upstream-type
+ -
+ name: upstream-phy-index
+ type: u32
+ -
+ name: upstream-sfp-name
+ type: string
+ -
+ name: downstream-sfp-name
+ type: string
+ -
+ name: id
+ type: u32

operations:
enum-model: directional
@@ -1696,3 +1733,25 @@ operations:
name: mm-ntf
doc: Notification for change in MAC Merge configuration.
notify: mm-get
+ -
+ name: phy-get
+ doc: Get PHY devices attached to an interface
+
+ attribute-set: phy
+
+ do: &phy-get-op
+ request:
+ attributes:
+ - header
+ reply:
+ attributes:
+ - header
+ - index
+ - drvname
+ - name
+ - upstream-type
+ - upstream-phy-index
+ - upstream-sfp-name
+ - downstream-sfp-name
+ - id
+ dump: *phy-get-op
--
2.43.2



2024-02-22 01:00:36

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next v8 08/13] netlink: specs: add ethnl PHY_GET command set

On Tue, 20 Feb 2024 19:42:11 +0100 Maxime Chevallier wrote:
> + -
> + name: upstream-phy-index
> + type: u32

The C define appears to be called:

ETHTOOL_A_PHY_UPSTREAM_INDEX, /* u32 */

either it needs to gain the PHY_ or the spec needs to lose the phy-,
otherwise C code gen gets upset:

ethtool-user.c:689:10: error: ‘ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX’ undeclared here (not in a function); did you mean ‘ETHTOOL_A_PHY_UPSTREAM_INDEX’?
689 | [ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX] = { .name = "upstream-phy-index", .type = YNL_PT_U32, },
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ETHTOOL_A_PHY_UPSTREAM_INDEX

Unfortunately ethtool in the in-between state where we can auto-gen
user space code (or rather most of it) but the uAPI header is not
auto-generated so we need to take extra care to keep things in sync :(

2024-02-22 07:50:15

by Maxime Chevallier

[permalink] [raw]
Subject: Re: [PATCH net-next v8 08/13] netlink: specs: add ethnl PHY_GET command set

Hello Jakub,

On Wed, 21 Feb 2024 17:00:23 -0800
Jakub Kicinski <[email protected]> wrote:

> On Tue, 20 Feb 2024 19:42:11 +0100 Maxime Chevallier wrote:
> > + -
> > + name: upstream-phy-index
> > + type: u32
>
> The C define appears to be called:
>
> ETHTOOL_A_PHY_UPSTREAM_INDEX, /* u32 */
>
> either it needs to gain the PHY_ or the spec needs to lose the phy-,
> otherwise C code gen gets upset:

I'll do it, sorry about that.

>
> ethtool-user.c:689:10: error: ‘ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX’ undeclared here (not in a function); did you mean ‘ETHTOOL_A_PHY_UPSTREAM_INDEX’?
> 689 | [ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX] = { .name = "upstream-phy-index", .type = YNL_PT_U32, },
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | ETHTOOL_A_PHY_UPSTREAM_INDEX
>
> Unfortunately ethtool in the in-between state where we can auto-gen
> user space code (or rather most of it) but the uAPI header is not
> auto-generated so we need to take extra care to keep things in sync :(

Is there anything I run for testing, so that I can make sure this
doesn't happen again ?

Thanks,

Maxime


2024-02-22 23:16:31

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next v8 08/13] netlink: specs: add ethnl PHY_GET command set

On Thu, 22 Feb 2024 08:49:48 +0100 Maxime Chevallier wrote:
> > ethtool-user.c:689:10: error: ‘ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX’ undeclared here (not in a function); did you mean ‘ETHTOOL_A_PHY_UPSTREAM_INDEX’?
> > 689 | [ETHTOOL_A_PHY_UPSTREAM_PHY_INDEX] = { .name = "upstream-phy-index", .type = YNL_PT_U32, },
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > | ETHTOOL_A_PHY_UPSTREAM_INDEX
> >
> > Unfortunately ethtool in the in-between state where we can auto-gen
> > user space code (or rather most of it) but the uAPI header is not
> > auto-generated so we need to take extra care to keep things in sync :(
>
> Is there anything I run for testing, so that I can make sure this
> doesn't happen again ?

make -C tools/net/ynl

will run the build. It needs some basic python libs, should be easy to
figure out from stack traces if they are missing.

I didn't mention it to you because.. it may not build for you on
net-next until what I'm about to post gets merged.