[RFC PATCH net-next 5/7] netlink: specs: add phy_list command

From: Maxime Chevallier
Date: Thu Sep 07 2023 - 11:39:14 EST


Add a new command allowing to list PHYs that are present on a
netdevice's link. The list is an array of phyindex, per-netdevice unique
numbers that describe a PHY device.

Example messages :

- No PHY on the link (Pure SFP interface) :

./cli.py --spec specs/ethtool.yaml --schema genetlink-legacy.yaml \
--do phy-list-get --json '{"header" : {"dev-name" : "eth3"}}'
{'header': {'dev-index': 5, 'dev-name': 'eth3'}, 'phy-count': 0}

- One PHY on the link :

./cli.py --spec specs/ethtool.yaml --schema genetlink-legacy.yaml \
--do phy-list-get --json '{"header" : {"dev-name" : "eth2"}}'
{'header': {'dev-index': 4, 'dev-name': 'eth2'},
'phy-count': 1,
'phy-indices': b'\x01\x00\x00\x00'}

- 2 PHYs on the link (MAC - PHY - SFP[PHY]) :

./cli.py --spec specs/ethtool.yaml --schema genetlink-legacy.yaml \
--do phy-list-get --json '{"header" : {"dev-name" : "eth0"}}'
{'header': {'dev-index': 2, 'dev-name': 'eth0'},
'phy-count': 2,
'phy-indices': b'\x02\x00\x00\x00\x01\x00\x00\x00'}

This PHY inddices can then be used by other netlink commands that would
target PHYs.

Signed-off-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
---
Documentation/netlink/specs/ethtool.yaml | 28 ++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml
index 837b565577ca..1139c88ed65c 100644
--- a/Documentation/netlink/specs/ethtool.yaml
+++ b/Documentation/netlink/specs/ethtool.yaml
@@ -942,6 +942,19 @@ attribute-sets:
-
name: burst-tmr
type: u32
+ -
+ name: phy-list
+ attributes:
+ -
+ name: header
+ type: nest
+ nested-attributes: header
+ -
+ name: phy-count
+ type: u8
+ -
+ name: phy-indices
+ type: binary

operations:
enum-model: directional
@@ -1692,3 +1705,18 @@ operations:
name: mm-ntf
doc: Notification for change in MAC Merge configuration.
notify: mm-get
+ -
+ name: phy-list-get
+ doc: Get list of PHY devices attached to an interface
+
+ attribute-set: phy-list
+
+ do: &phy-list-get-op
+ request:
+ attributes:
+ - header
+ reply:
+ attributes:
+ - header
+ - phy-count
+ - phy-indices
--
2.41.0