Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "Introduce PHY listing and link_topology tracking"

This reverts commit 32bb4515e34469975abc936deb0a116c4a445817.
This reverts commit d078d480639a4f3b5fc2d56247afa38e0956483a.
This reverts commit fcc4b105caa4b844bf043375bf799c20a9c99db1.
This reverts commit 345237dbc1bdbb274c9fb9ec38976261ff4a40b8.
This reverts commit 7db69ec9cfb8b4ab50420262631fb2d1908b25bf.
This reverts commit 95132a018f00f5dad38bdcfd4180d1af955d46f6.
This reverts commit 63d5eaf35ac36cad00cfb3809d794ef0078c822b.
This reverts commit c29451aefcb42359905d18678de38e52eccb3bb5.
This reverts commit 2ab0edb505faa9ac90dee1732571390f074e8113.
This reverts commit dedd702a35793ab462fce4c737eeba0badf9718e.
This reverts commit 034fcc210349b873ece7356905be5c6ca11eef2a.
This reverts commit 9c5625f559ad6fe9f6f733c11475bf470e637d34.
This reverts commit 02018c544ef113e980a2349eba89003d6f399d22.

Looks like we need more time for reviews, and incremental
changes will be hard to make sense of. So revert.

Link: https://lore.kernel.org/all/ZZP6FV5sXEf+xd58@shell.armlinux.org.uk/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+35 -912
-68
Documentation/netlink/specs/ethtool.yaml
··· 16 16 name: stringset 17 17 type: enum 18 18 entries: [] 19 - - 20 - name: phy-upstream-type 21 - enum-name: 22 - type: enum 23 - entries: [ mac, phy ] 24 19 25 20 attribute-sets: 26 21 - ··· 29 34 type: string 30 35 - 31 36 name: flags 32 - type: u32 33 - - 34 - name: phy-index 35 37 type: u32 36 38 37 39 - ··· 942 950 - 943 951 name: burst-tmr 944 952 type: u32 945 - - 946 - name: phy-upstream 947 - attributes: 948 - - 949 - name: index 950 - type: u32 951 - - 952 - name: sfp-name 953 - type: string 954 - - 955 - name: phy 956 - attributes: 957 - - 958 - name: header 959 - type: nest 960 - nested-attributes: header 961 - - 962 - name: index 963 - type: u32 964 - - 965 - name: drvname 966 - type: string 967 - - 968 - name: name 969 - type: string 970 - - 971 - name: upstream-type 972 - type: u8 973 - enum: phy-upstream-type 974 - - 975 - name: upstream 976 - type: nest 977 - nested-attributes: phy-upstream 978 - - 979 - name: downstream-sfp-name 980 - type: string 981 - - 982 - name: id 983 - type: u32 984 953 985 954 operations: 986 955 enum-model: directional ··· 1693 1740 name: mm-ntf 1694 1741 doc: Notification for change in MAC Merge configuration. 1695 1742 notify: mm-get 1696 - - 1697 - name: phy-get 1698 - doc: Get PHY devices attached to an interface 1699 - 1700 - attribute-set: phy 1701 - 1702 - do: &phy-get-op 1703 - request: 1704 - attributes: 1705 - - header 1706 - reply: 1707 - attributes: 1708 - - header 1709 - - index 1710 - - drvname 1711 - - name 1712 - - upstream-type 1713 - - upstream 1714 - - downstream-sfp-name 1715 - - id 1716 - dump: *phy-get-op
-51
Documentation/networking/ethtool-netlink.rst
··· 57 57 ``ETHTOOL_A_HEADER_DEV_INDEX`` u32 device ifindex 58 58 ``ETHTOOL_A_HEADER_DEV_NAME`` string device name 59 59 ``ETHTOOL_A_HEADER_FLAGS`` u32 flags common for all requests 60 - ``ETHTOOL_A_HEADER_PHY_INDEX`` u32 phy device index 61 60 ============================== ====== ============================= 62 61 63 62 ``ETHTOOL_A_HEADER_DEV_INDEX`` and ``ETHTOOL_A_HEADER_DEV_NAME`` identify the ··· 81 82 of the flag should be interpreted the way the client expects. A client must 82 83 not set flags it does not understand. 83 84 84 - ``ETHTOOL_A_HEADER_PHY_INDEX`` identify the ethernet PHY the message relates to. 85 - As there are numerous commands that are related to PHY configuration, and because 86 - we can have more than one PHY on the link, the PHY index can be passed in the 87 - request for the commands that needs it. It is however not mandatory, and if it 88 - is not passed for commands that target a PHY, the net_device.phydev pointer 89 - is used, as a fallback that keeps the legacy behaviour. 90 85 91 86 Bit sets 92 87 ======== ··· 2004 2011 .. kernel-doc:: include/linux/ethtool.h 2005 2012 :identifiers: ethtool_mm_cfg 2006 2013 2007 - PHY_GET 2008 - ======= 2009 - 2010 - Retrieve information about a given Ethernet PHY sitting on the link. As there 2011 - can be more than one PHY, the DUMP operation can be used to list the PHYs 2012 - present on a given interface, by passing an interface index or name in 2013 - the dump request 2014 - 2015 - Request contents: 2016 - 2017 - ==================================== ====== ========================== 2018 - ``ETHTOOL_A_PHY_HEADER`` nested request header 2019 - ==================================== ====== ========================== 2020 - 2021 - Kernel response contents: 2022 - 2023 - ===================================== ====== ========================== 2024 - ``ETHTOOL_A_PHY_HEADER`` nested request header 2025 - ``ETHTOOL_A_PHY_INDEX`` u32 the phy's unique index, that can 2026 - be used for phy-specific requests 2027 - ``ETHTOOL_A_PHY_DRVNAME`` string the phy driver name 2028 - ``ETHTOOL_A_PHY_NAME`` string the phy device name 2029 - ``ETHTOOL_A_PHY_UPSTREAM_TYPE`` u32 the type of device this phy is 2030 - connected to 2031 - ``ETHTOOL_A_PHY_UPSTREAM_PHY`` nested if the phy is connected to another 2032 - phy, this nest contains info on 2033 - that connection 2034 - ``ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME`` string if the phy controls an sfp bus, 2035 - the name of the sfp bus 2036 - ``ETHTOOL_A_PHY_ID`` u32 the phy id if the phy is C22 2037 - ===================================== ====== ========================== 2038 - 2039 - When ``ETHTOOL_A_PHY_UPSTREAM_TYPE`` is PHY_UPSTREAM_PHY, the PHY's parent is 2040 - another PHY. Information on the parent PHY will be set in the 2041 - ``ETHTOOL_A_PHY_UPSTREAM_PHY`` nest, which has the following structure : 2042 - 2043 - =================================== ====== ========================== 2044 - ``ETHTOOL_A_PHY_UPSTREAM_INDEX`` u32 the PHY index of the upstream PHY 2045 - ``ETHTOOL_A_PHY_UPSTREAM_SFP_NAME`` string if this PHY is connected to it's 2046 - parent PHY through an SFP bus, the 2047 - name of this sfp bus 2048 - =================================== ====== ========================== 2049 - 2050 2014 Request translation 2051 2015 =================== 2052 2016 ··· 2110 2160 n/a ``ETHTOOL_MSG_PLCA_GET_STATUS`` 2111 2161 n/a ``ETHTOOL_MSG_MM_GET`` 2112 2162 n/a ``ETHTOOL_MSG_MM_SET`` 2113 - n/a ``ETHTOOL_MSG_PHY_GET`` 2114 2163 =================================== =====================================
-1
Documentation/networking/index.rst
··· 88 88 operstates 89 89 packet_mmap 90 90 phonet 91 - phy-link-topology 92 91 pktgen 93 92 plip 94 93 ppp_generic
-2
MAINTAINERS
··· 7871 7871 F: include/linux/of_net.h 7872 7872 F: include/linux/phy.h 7873 7873 F: include/linux/phy_fixed.h 7874 - F: include/linux/phy_link_topology.h 7875 - F: include/linux/phy_link_topology_core.h 7876 7874 F: include/linux/phylib_stubs.h 7877 7875 F: include/linux/platform_data/mdio-bcm-unimac.h 7878 7876 F: include/linux/platform_data/mdio-gpio.h
+1 -1
drivers/net/phy/Makefile
··· 2 2 # Makefile for Linux PHY drivers 3 3 4 4 libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \ 5 - linkmode.o phy_link_topology.o 5 + linkmode.o 6 6 mdio-bus-y += mdio_bus.o mdio_device.o 7 7 8 8 ifdef CONFIG_MDIO_DEVICE
-2
drivers/net/phy/at803x.c
··· 1452 1452 .attach = phy_sfp_attach, 1453 1453 .detach = phy_sfp_detach, 1454 1454 .module_insert = at8031_sfp_insert, 1455 - .connect_phy = phy_sfp_connect_phy, 1456 - .disconnect_phy = phy_sfp_disconnect_phy, 1457 1455 }; 1458 1456 1459 1457 static int at8031_parse_dt(struct phy_device *phydev)
-2
drivers/net/phy/marvell-88x2222.c
··· 555 555 .link_down = mv2222_sfp_link_down, 556 556 .attach = phy_sfp_attach, 557 557 .detach = phy_sfp_detach, 558 - .connect_phy = phy_sfp_connect_phy, 559 - .disconnect_phy = phy_sfp_disconnect_phy, 560 558 }; 561 559 562 560 static int mv2222_probe(struct phy_device *phydev)
-2
drivers/net/phy/marvell.c
··· 3254 3254 .module_remove = m88e1510_sfp_remove, 3255 3255 .attach = phy_sfp_attach, 3256 3256 .detach = phy_sfp_detach, 3257 - .connect_phy = phy_sfp_connect_phy, 3258 - .disconnect_phy = phy_sfp_disconnect_phy, 3259 3257 }; 3260 3258 3261 3259 static int m88e1510_probe(struct phy_device *phydev)
-2
drivers/net/phy/marvell10g.c
··· 503 503 static const struct sfp_upstream_ops mv3310_sfp_ops = { 504 504 .attach = phy_sfp_attach, 505 505 .detach = phy_sfp_detach, 506 - .connect_phy = phy_sfp_connect_phy, 507 - .disconnect_phy = phy_sfp_disconnect_phy, 508 506 .module_insert = mv3310_sfp_insert, 509 507 }; 510 508
-55
drivers/net/phy/phy_device.c
··· 29 29 #include <linux/phy.h> 30 30 #include <linux/phylib_stubs.h> 31 31 #include <linux/phy_led_triggers.h> 32 - #include <linux/phy_link_topology.h> 33 32 #include <linux/pse-pd/pse.h> 34 33 #include <linux/property.h> 35 34 #include <linux/rtnetlink.h> ··· 264 265 } 265 266 266 267 static struct phy_driver genphy_driver; 267 - 268 - static struct phy_link_topology *phy_get_link_topology(struct phy_device *phydev) 269 - { 270 - if (phydev->attached_dev) 271 - return &phydev->attached_dev->link_topo; 272 - 273 - return NULL; 274 - } 275 268 276 269 static LIST_HEAD(phy_fixup_list); 277 270 static DEFINE_MUTEX(phy_fixup_lock); ··· 1355 1364 static DEVICE_ATTR_RO(phy_standalone); 1356 1365 1357 1366 /** 1358 - * phy_sfp_connect_phy - Connect the SFP module's PHY to the upstream PHY 1359 - * @upstream: pointer to the upstream phy device 1360 - * @phy: pointer to the SFP module's phy device 1361 - * 1362 - * This helper allows keeping track of PHY devices on the link. It adds the 1363 - * SFP module's phy to the phy namespace of the upstream phy 1364 - */ 1365 - int phy_sfp_connect_phy(void *upstream, struct phy_device *phy) 1366 - { 1367 - struct phy_device *phydev = upstream; 1368 - struct phy_link_topology *topo = phy_get_link_topology(phydev); 1369 - 1370 - if (topo) 1371 - return phy_link_topo_add_phy(topo, phy, PHY_UPSTREAM_PHY, phydev); 1372 - 1373 - return 0; 1374 - } 1375 - EXPORT_SYMBOL(phy_sfp_connect_phy); 1376 - 1377 - /** 1378 - * phy_sfp_disconnect_phy - Disconnect the SFP module's PHY from the upstream PHY 1379 - * @upstream: pointer to the upstream phy device 1380 - * @phy: pointer to the SFP module's phy device 1381 - * 1382 - * This helper allows keeping track of PHY devices on the link. It removes the 1383 - * SFP module's phy to the phy namespace of the upstream phy. As the module phy 1384 - * will be destroyed, re-inserting the same module will add a new phy with a 1385 - * new index. 1386 - */ 1387 - void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy) 1388 - { 1389 - struct phy_device *phydev = upstream; 1390 - struct phy_link_topology *topo = phy_get_link_topology(phydev); 1391 - 1392 - if (topo) 1393 - phy_link_topo_del_phy(topo, phy); 1394 - } 1395 - EXPORT_SYMBOL(phy_sfp_disconnect_phy); 1396 - 1397 - /** 1398 1367 * phy_sfp_attach - attach the SFP bus to the PHY upstream network device 1399 1368 * @upstream: pointer to the phy device 1400 1369 * @bus: sfp bus representing cage being attached ··· 1491 1540 1492 1541 if (phydev->sfp_bus_attached) 1493 1542 dev->sfp_bus = phydev->sfp_bus; 1494 - 1495 - err = phy_link_topo_add_phy(&dev->link_topo, phydev, 1496 - PHY_UPSTREAM_MAC, dev); 1497 - if (err) 1498 - goto error; 1499 1543 } 1500 1544 1501 1545 /* Some Ethernet drivers try to connect to a PHY device before ··· 1820 1874 if (dev) { 1821 1875 phydev->attached_dev->phydev = NULL; 1822 1876 phydev->attached_dev = NULL; 1823 - phy_link_topo_del_phy(&dev->link_topo, phydev); 1824 1877 } 1825 1878 phydev->phylink = NULL; 1826 1879
+1 -2
drivers/net/phy/phylink.c
··· 3385 3385 return ret; 3386 3386 } 3387 3387 3388 - static void phylink_sfp_disconnect_phy(void *upstream, 3389 - struct phy_device *phydev) 3388 + static void phylink_sfp_disconnect_phy(void *upstream) 3390 3389 { 3391 3390 phylink_disconnect_phy(upstream); 3392 3391 }
+2 -13
drivers/net/phy/sfp-bus.c
··· 486 486 bus->socket_ops->stop(bus->sfp); 487 487 bus->socket_ops->detach(bus->sfp); 488 488 if (bus->phydev && ops && ops->disconnect_phy) 489 - ops->disconnect_phy(bus->upstream, bus->phydev); 489 + ops->disconnect_phy(bus->upstream); 490 490 } 491 491 bus->registered = false; 492 492 } ··· 742 742 const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus); 743 743 744 744 if (ops && ops->disconnect_phy) 745 - ops->disconnect_phy(bus->upstream, bus->phydev); 745 + ops->disconnect_phy(bus->upstream); 746 746 bus->phydev = NULL; 747 747 } 748 748 EXPORT_SYMBOL_GPL(sfp_remove_phy); ··· 859 859 sfp_bus_put(bus); 860 860 } 861 861 EXPORT_SYMBOL_GPL(sfp_unregister_socket); 862 - 863 - const char *sfp_get_name(struct sfp_bus *bus) 864 - { 865 - ASSERT_RTNL(); 866 - 867 - if (bus->sfp_dev) 868 - return dev_name(bus->sfp_dev); 869 - 870 - return NULL; 871 - } 872 - EXPORT_SYMBOL_GPL(sfp_get_name);
+1 -3
include/linux/netdevice.h
··· 40 40 #include <net/dcbnl.h> 41 41 #endif 42 42 #include <net/netprio_cgroup.h> 43 + 43 44 #include <linux/netdev_features.h> 44 45 #include <linux/neighbour.h> 45 46 #include <uapi/linux/netdevice.h> ··· 52 51 #include <net/net_trackers.h> 53 52 #include <net/net_debug.h> 54 53 #include <net/dropreason-core.h> 55 - #include <linux/phy_link_topology_core.h> 56 54 57 55 struct netpoll_info; 58 56 struct device; ··· 2047 2047 * @fcoe_ddp_xid: Max exchange id for FCoE LRO by ddp 2048 2048 * 2049 2049 * @priomap: XXX: need comments on this one 2050 - * @link_topo: Physical link topology tracking attached PHYs 2051 2050 * @phydev: Physical device may attach itself 2052 2051 * for hardware timestamping 2053 2052 * @sfp_bus: attached &struct sfp_bus structure. ··· 2441 2442 #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) 2442 2443 struct netprio_map __rcu *priomap; 2443 2444 #endif 2444 - struct phy_link_topology link_topo; 2445 2445 struct phy_device *phydev; 2446 2446 struct sfp_bus *sfp_bus; 2447 2447 struct lock_class_key *qdisc_tx_busylock;
-6
include/linux/phy.h
··· 544 544 * @drv: Pointer to the driver for this PHY instance 545 545 * @devlink: Create a link between phy dev and mac dev, if the external phy 546 546 * used by current mac interface is managed by another mac interface. 547 - * @phyindex: Unique id across the phy's parent tree of phys to address the PHY 548 - * from userspace, similar to ifindex. A zero index means the PHY 549 - * wasn't assigned an id yet. 550 547 * @phy_id: UID for this device found during discovery 551 548 * @c45_ids: 802.3-c45 Device Identifiers if is_c45. 552 549 * @is_c45: Set to true if this PHY uses clause 45 addressing. ··· 643 646 644 647 struct device_link *devlink; 645 648 646 - u32 phyindex; 647 649 u32 phy_id; 648 650 649 651 struct phy_c45_device_ids c45_ids; ··· 1722 1726 int phy_resume(struct phy_device *phydev); 1723 1727 int __phy_resume(struct phy_device *phydev); 1724 1728 int phy_loopback(struct phy_device *phydev, bool enable); 1725 - int phy_sfp_connect_phy(void *upstream, struct phy_device *phy); 1726 - void phy_sfp_disconnect_phy(void *upstream, struct phy_device *phy); 1727 1729 void phy_sfp_attach(void *upstream, struct sfp_bus *bus); 1728 1730 void phy_sfp_detach(void *upstream, struct sfp_bus *bus); 1729 1731 int phy_sfp_probe(struct phy_device *phydev,
+1 -7
include/linux/sfp.h
··· 544 544 void (*link_down)(void *priv); 545 545 void (*link_up)(void *priv); 546 546 int (*connect_phy)(void *priv, struct phy_device *); 547 - void (*disconnect_phy)(void *priv, struct phy_device *); 547 + void (*disconnect_phy)(void *priv); 548 548 }; 549 549 550 550 #if IS_ENABLED(CONFIG_SFP) ··· 570 570 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, 571 571 const struct sfp_upstream_ops *ops); 572 572 void sfp_bus_del_upstream(struct sfp_bus *bus); 573 - const char *sfp_get_name(struct sfp_bus *bus); 574 573 #else 575 574 static inline int sfp_parse_port(struct sfp_bus *bus, 576 575 const struct sfp_eeprom_id *id, ··· 647 648 648 649 static inline void sfp_bus_del_upstream(struct sfp_bus *bus) 649 650 { 650 - } 651 - 652 - static inline const char *sfp_get_name(struct sfp_bus *bus) 653 - { 654 - return NULL; 655 651 } 656 652 #endif 657 653
-16
include/uapi/linux/ethtool.h
··· 2220 2220 * __u32 map_lp_advertising[link_mode_masks_nwords]; 2221 2221 */ 2222 2222 }; 2223 - 2224 - /** 2225 - * enum phy_upstream - Represents the upstream component a given PHY device 2226 - * is connected to, as in what is on the other end of the MII bus. Most PHYs 2227 - * will be attached to an Ethernet MAC controller, but in some cases, there's 2228 - * an intermediate PHY used as a media-converter, which will driver another 2229 - * MII interface as its output. 2230 - * @PHY_UPSTREAM_MAC: Upstream component is a MAC (a switch port, 2231 - * or ethernet controller) 2232 - * @PHY_UPSTREAM_PHY: Upstream component is a PHY (likely a media converter) 2233 - */ 2234 - enum phy_upstream { 2235 - PHY_UPSTREAM_MAC, 2236 - PHY_UPSTREAM_PHY, 2237 - }; 2238 - 2239 2223 #endif /* _UAPI_LINUX_ETHTOOL_H */
-30
include/uapi/linux/ethtool_netlink.h
··· 57 57 ETHTOOL_MSG_PLCA_GET_STATUS, 58 58 ETHTOOL_MSG_MM_GET, 59 59 ETHTOOL_MSG_MM_SET, 60 - ETHTOOL_MSG_PHY_GET, 61 60 62 61 /* add new constants above here */ 63 62 __ETHTOOL_MSG_USER_CNT, ··· 109 110 ETHTOOL_MSG_PLCA_NTF, 110 111 ETHTOOL_MSG_MM_GET_REPLY, 111 112 ETHTOOL_MSG_MM_NTF, 112 - ETHTOOL_MSG_PHY_GET_REPLY, 113 - ETHTOOL_MSG_PHY_NTF, 114 113 115 114 /* add new constants above here */ 116 115 __ETHTOOL_MSG_KERNEL_CNT, ··· 133 136 ETHTOOL_A_HEADER_DEV_INDEX, /* u32 */ 134 137 ETHTOOL_A_HEADER_DEV_NAME, /* string */ 135 138 ETHTOOL_A_HEADER_FLAGS, /* u32 - ETHTOOL_FLAG_* */ 136 - ETHTOOL_A_HEADER_PHY_INDEX, /* u32 */ 137 139 138 140 /* add new constants above here */ 139 141 __ETHTOOL_A_HEADER_CNT, ··· 974 978 /* add new constants above here */ 975 979 __ETHTOOL_A_MM_CNT, 976 980 ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) 977 - }; 978 - 979 - enum { 980 - ETHTOOL_A_PHY_UPSTREAM_UNSPEC, 981 - ETHTOOL_A_PHY_UPSTREAM_INDEX, /* u32 */ 982 - ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, /* string */ 983 - 984 - /* add new constants above here */ 985 - __ETHTOOL_A_PHY_UPSTREAM_CNT, 986 - ETHTOOL_A_PHY_UPSTREAM_MAX = (__ETHTOOL_A_PHY_UPSTREAM_CNT - 1) 987 - }; 988 - 989 - enum { 990 - ETHTOOL_A_PHY_UNSPEC, 991 - ETHTOOL_A_PHY_HEADER, /* nest - _A_HEADER_* */ 992 - ETHTOOL_A_PHY_INDEX, /* u32 */ 993 - ETHTOOL_A_PHY_DRVNAME, /* string */ 994 - ETHTOOL_A_PHY_NAME, /* string */ 995 - ETHTOOL_A_PHY_UPSTREAM_TYPE, /* u8 */ 996 - ETHTOOL_A_PHY_UPSTREAM, /* nest - _A_PHY_UPSTREAM_* */ 997 - ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, /* string */ 998 - ETHTOOL_A_PHY_ID, /* u32 */ 999 - 1000 - /* add new constants above here */ 1001 - __ETHTOOL_A_PHY_CNT, 1002 - ETHTOOL_A_PHY_MAX = (__ETHTOOL_A_PHY_CNT - 1) 1003 981 }; 1004 982 1005 983 /* generic netlink info */
-3
net/core/dev.c
··· 153 153 #include <linux/prandom.h> 154 154 #include <linux/once_lite.h> 155 155 #include <net/netdev_rx_queue.h> 156 - #include <linux/phy_link_topology_core.h> 157 156 158 157 #include "dev.h" 159 158 #include "net-sysfs.h" ··· 10875 10876 #ifdef CONFIG_NET_SCHED 10876 10877 hash_init(dev->qdisc_hash); 10877 10878 #endif 10878 - phy_link_topo_init(&dev->link_topo); 10879 - 10880 10879 dev->priv_flags = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM; 10881 10880 setup(dev); 10882 10881
+1 -1
net/ethtool/Makefile
··· 8 8 linkstate.o debug.o wol.o features.o privflags.o rings.o \ 9 9 channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ 10 10 tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ 11 - module.o pse-pd.o plca.o mm.o phy.o 11 + module.o pse-pd.o plca.o mm.o
+6 -6
net/ethtool/cabletest.c
··· 69 69 return ret; 70 70 71 71 dev = req_info.dev; 72 - if (!req_info.phydev) { 72 + if (!dev->phydev) { 73 73 ret = -EOPNOTSUPP; 74 74 goto out_dev_put; 75 75 } ··· 85 85 if (ret < 0) 86 86 goto out_rtnl; 87 87 88 - ret = ops->start_cable_test(req_info.phydev, info->extack); 88 + ret = ops->start_cable_test(dev->phydev, info->extack); 89 89 90 90 ethnl_ops_complete(dev); 91 91 92 92 if (!ret) 93 - ethnl_cable_test_started(req_info.phydev, 93 + ethnl_cable_test_started(dev->phydev, 94 94 ETHTOOL_MSG_CABLE_TEST_NTF); 95 95 96 96 out_rtnl: ··· 321 321 return ret; 322 322 323 323 dev = req_info.dev; 324 - if (!req_info.phydev) { 324 + if (!dev->phydev) { 325 325 ret = -EOPNOTSUPP; 326 326 goto out_dev_put; 327 327 } ··· 342 342 if (ret < 0) 343 343 goto out_rtnl; 344 344 345 - ret = ops->start_cable_test_tdr(req_info.phydev, info->extack, &cfg); 345 + ret = ops->start_cable_test_tdr(dev->phydev, info->extack, &cfg); 346 346 347 347 ethnl_ops_complete(dev); 348 348 349 349 if (!ret) 350 - ethnl_cable_test_started(req_info.phydev, 350 + ethnl_cable_test_started(dev->phydev, 351 351 ETHTOOL_MSG_CABLE_TEST_TDR_NTF); 352 352 353 353 out_rtnl:
-33
net/ethtool/netlink.c
··· 4 4 #include <linux/ethtool_netlink.h> 5 5 #include <linux/pm_runtime.h> 6 6 #include "netlink.h" 7 - #include <linux/phy_link_topology.h> 8 7 9 8 static struct genl_family ethtool_genl_family; 10 9 ··· 20 21 .len = ALTIFNAMSIZ - 1 }, 21 22 [ETHTOOL_A_HEADER_FLAGS] = NLA_POLICY_MASK(NLA_U32, 22 23 ETHTOOL_FLAGS_BASIC), 23 - [ETHTOOL_A_HEADER_PHY_INDEX] = NLA_POLICY_MIN(NLA_U32, 1), 24 24 }; 25 25 26 26 const struct nla_policy ethnl_header_policy_stats[] = { ··· 28 30 .len = ALTIFNAMSIZ - 1 }, 29 31 [ETHTOOL_A_HEADER_FLAGS] = NLA_POLICY_MASK(NLA_U32, 30 32 ETHTOOL_FLAGS_STATS), 31 - [ETHTOOL_A_HEADER_PHY_INDEX] = NLA_POLICY_MIN(NLA_U32, 1), 32 33 }; 33 34 34 35 int ethnl_ops_begin(struct net_device *dev) ··· 91 94 { 92 95 struct nlattr *tb[ARRAY_SIZE(ethnl_header_policy)]; 93 96 const struct nlattr *devname_attr; 94 - struct phy_device *phydev = NULL; 95 97 struct net_device *dev = NULL; 96 98 u32 flags = 0; 97 99 int ret; ··· 145 149 return -EINVAL; 146 150 } 147 151 148 - if (dev) { 149 - if (tb[ETHTOOL_A_HEADER_PHY_INDEX]) { 150 - u32 phy_index = nla_get_u32(tb[ETHTOOL_A_HEADER_PHY_INDEX]); 151 - 152 - phydev = phy_link_topo_get_phy(&dev->link_topo, 153 - phy_index); 154 - if (!phydev) { 155 - NL_SET_ERR_MSG_ATTR(extack, header, 156 - "no phy matches phy index"); 157 - return -EINVAL; 158 - } 159 - } else { 160 - /* If we need a PHY but no phy index is specified, fallback 161 - * to dev->phydev 162 - */ 163 - phydev = dev->phydev; 164 - } 165 - } 166 - 167 - req_info->phydev = phydev; 168 152 req_info->dev = dev; 169 153 req_info->flags = flags; 170 154 return 0; ··· 1128 1152 .doit = ethnl_default_set_doit, 1129 1153 .policy = ethnl_mm_set_policy, 1130 1154 .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, 1131 - }, 1132 - { 1133 - .cmd = ETHTOOL_MSG_PHY_GET, 1134 - .doit = ethnl_phy_doit, 1135 - .start = ethnl_phy_start, 1136 - .dumpit = ethnl_phy_dumpit, 1137 - .done = ethnl_phy_done, 1138 - .policy = ethnl_phy_get_policy, 1139 - .maxattr = ARRAY_SIZE(ethnl_phy_get_policy) - 1, 1140 1155 }, 1141 1156 }; 1142 1157
+2 -10
net/ethtool/netlink.h
··· 250 250 * @dev: network device the request is for (may be null) 251 251 * @dev_tracker: refcount tracker for @dev reference 252 252 * @flags: request flags common for all request types 253 - * @phydev: phy_device connected to @dev this request is for (may be null) 254 253 * 255 254 * This is a common base for request specific structures holding data from 256 255 * parsed userspace request. These always embed struct ethnl_req_info at ··· 259 260 struct net_device *dev; 260 261 netdevice_tracker dev_tracker; 261 262 u32 flags; 262 - struct phy_device *phydev; 263 263 }; 264 264 265 265 static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info) ··· 395 397 extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; 396 398 extern const struct ethnl_request_ops ethnl_plca_status_request_ops; 397 399 extern const struct ethnl_request_ops ethnl_mm_request_ops; 398 - extern const struct ethnl_request_ops ethnl_phy_request_ops; 399 400 400 - extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_PHY_INDEX + 1]; 401 - extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_PHY_INDEX + 1]; 401 + extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; 402 + extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; 402 403 extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_COUNTS_ONLY + 1]; 403 404 extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1]; 404 405 extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1]; ··· 441 444 extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; 442 445 extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; 443 446 extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; 444 - extern const struct nla_policy ethnl_phy_get_policy[ETHTOOL_A_PHY_HEADER + 1]; 445 447 446 448 int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); 447 449 int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info); ··· 448 452 int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info); 449 453 int ethnl_tunnel_info_start(struct netlink_callback *cb); 450 454 int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb); 451 - int ethnl_phy_start(struct netlink_callback *cb); 452 - int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info); 453 - int ethnl_phy_dumpit(struct sk_buff *skb, struct netlink_callback *cb); 454 - int ethnl_phy_done(struct netlink_callback *cb); 455 455 456 456 extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN]; 457 457 extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN];
-306
net/ethtool/phy.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright 2023 Bootlin 4 - * 5 - */ 6 - #include "common.h" 7 - #include "netlink.h" 8 - 9 - #include <linux/phy.h> 10 - #include <linux/phy_link_topology.h> 11 - #include <linux/sfp.h> 12 - 13 - struct phy_req_info { 14 - struct ethnl_req_info base; 15 - struct phy_device_node pdn; 16 - }; 17 - 18 - #define PHY_REQINFO(__req_base) \ 19 - container_of(__req_base, struct phy_req_info, base) 20 - 21 - const struct nla_policy ethnl_phy_get_policy[ETHTOOL_A_PHY_HEADER + 1] = { 22 - [ETHTOOL_A_PHY_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), 23 - }; 24 - 25 - /* Caller holds rtnl */ 26 - static ssize_t 27 - ethnl_phy_reply_size(const struct ethnl_req_info *req_base, 28 - struct netlink_ext_ack *extack) 29 - { 30 - struct phy_link_topology *topo; 31 - struct phy_device_node *pdn; 32 - struct phy_device *phydev; 33 - unsigned long index; 34 - size_t size; 35 - 36 - ASSERT_RTNL(); 37 - 38 - topo = &req_base->dev->link_topo; 39 - 40 - size = nla_total_size(0); 41 - 42 - xa_for_each(&topo->phys, index, pdn) { 43 - phydev = pdn->phy; 44 - 45 - /* ETHTOOL_A_PHY_INDEX */ 46 - size += nla_total_size(sizeof(u32)); 47 - 48 - /* ETHTOOL_A_DRVNAME */ 49 - size += nla_total_size(strlen(phydev->drv->name) + 1); 50 - 51 - /* ETHTOOL_A_NAME */ 52 - size += nla_total_size(strlen(dev_name(&phydev->mdio.dev)) + 1); 53 - 54 - /* ETHTOOL_A_PHY_UPSTREAM_TYPE */ 55 - size += nla_total_size(sizeof(u8)); 56 - 57 - /* ETHTOOL_A_PHY_ID */ 58 - size += nla_total_size(sizeof(u32)); 59 - 60 - if (phy_on_sfp(phydev)) { 61 - const char *upstream_sfp_name = sfp_get_name(pdn->parent_sfp_bus); 62 - 63 - /* ETHTOOL_A_PHY_UPSTREAM_SFP_NAME */ 64 - if (upstream_sfp_name) 65 - size += nla_total_size(strlen(upstream_sfp_name) + 1); 66 - 67 - /* ETHTOOL_A_PHY_UPSTREAM_INDEX */ 68 - size += nla_total_size(sizeof(u32)); 69 - } 70 - 71 - /* ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME */ 72 - if (phydev->sfp_bus) { 73 - const char *sfp_name = sfp_get_name(phydev->sfp_bus); 74 - 75 - if (sfp_name) 76 - size += nla_total_size(strlen(sfp_name) + 1); 77 - } 78 - } 79 - 80 - return size; 81 - } 82 - 83 - static int 84 - ethnl_phy_fill_reply(const struct ethnl_req_info *req_base, struct sk_buff *skb) 85 - { 86 - struct phy_req_info *req_info = PHY_REQINFO(req_base); 87 - struct phy_device_node *pdn = &req_info->pdn; 88 - struct phy_device *phydev = pdn->phy; 89 - enum phy_upstream ptype; 90 - struct nlattr *nest; 91 - 92 - ptype = pdn->upstream_type; 93 - 94 - if (nla_put_u32(skb, ETHTOOL_A_PHY_INDEX, phydev->phyindex) || 95 - nla_put_string(skb, ETHTOOL_A_PHY_DRVNAME, phydev->drv->name) || 96 - nla_put_string(skb, ETHTOOL_A_PHY_NAME, dev_name(&phydev->mdio.dev)) || 97 - nla_put_u8(skb, ETHTOOL_A_PHY_UPSTREAM_TYPE, ptype) || 98 - nla_put_u32(skb, ETHTOOL_A_PHY_ID, phydev->phy_id)) 99 - return -EMSGSIZE; 100 - 101 - if (ptype == PHY_UPSTREAM_PHY) { 102 - struct phy_device *upstream = pdn->upstream.phydev; 103 - const char *sfp_upstream_name; 104 - 105 - nest = nla_nest_start(skb, ETHTOOL_A_PHY_UPSTREAM); 106 - if (!nest) 107 - return -EMSGSIZE; 108 - 109 - /* Parent index */ 110 - if (nla_put_u32(skb, ETHTOOL_A_PHY_UPSTREAM_INDEX, upstream->phyindex)) 111 - return -EMSGSIZE; 112 - 113 - if (pdn->parent_sfp_bus) { 114 - sfp_upstream_name = sfp_get_name(pdn->parent_sfp_bus); 115 - if (sfp_upstream_name && nla_put_string(skb, 116 - ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, 117 - sfp_upstream_name)) 118 - return -EMSGSIZE; 119 - } 120 - 121 - nla_nest_end(skb, nest); 122 - } 123 - 124 - if (phydev->sfp_bus) { 125 - const char *sfp_name = sfp_get_name(phydev->sfp_bus); 126 - 127 - if (sfp_name && 128 - nla_put_string(skb, ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, 129 - sfp_name)) 130 - return -EMSGSIZE; 131 - } 132 - 133 - return 0; 134 - } 135 - 136 - static int ethnl_phy_parse_request(struct ethnl_req_info *req_base, 137 - struct nlattr **tb) 138 - { 139 - struct phy_link_topology *topo = &req_base->dev->link_topo; 140 - struct phy_req_info *req_info = PHY_REQINFO(req_base); 141 - struct phy_device_node *pdn; 142 - 143 - if (!req_base->phydev) 144 - return 0; 145 - 146 - pdn = xa_load(&topo->phys, req_base->phydev->phyindex); 147 - memcpy(&req_info->pdn, pdn, sizeof(*pdn)); 148 - 149 - return 0; 150 - } 151 - 152 - int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info) 153 - { 154 - struct phy_req_info req_info = {}; 155 - struct nlattr **tb = info->attrs; 156 - struct sk_buff *rskb; 157 - void *reply_payload; 158 - int reply_len; 159 - int ret; 160 - 161 - ret = ethnl_parse_header_dev_get(&req_info.base, 162 - tb[ETHTOOL_A_PHY_HEADER], 163 - genl_info_net(info), info->extack, 164 - true); 165 - if (ret < 0) 166 - return ret; 167 - 168 - rtnl_lock(); 169 - 170 - ret = ethnl_phy_parse_request(&req_info.base, tb); 171 - if (ret < 0) 172 - goto err_unlock_rtnl; 173 - 174 - /* No PHY, return early */ 175 - if (!req_info.pdn.phy) 176 - goto err_unlock_rtnl; 177 - 178 - ret = ethnl_phy_reply_size(&req_info.base, info->extack); 179 - if (ret < 0) 180 - goto err_unlock_rtnl; 181 - reply_len = ret + ethnl_reply_header_size(); 182 - 183 - rskb = ethnl_reply_init(reply_len, req_info.base.dev, 184 - ETHTOOL_MSG_PHY_GET_REPLY, 185 - ETHTOOL_A_PHY_HEADER, 186 - info, &reply_payload); 187 - if (!rskb) { 188 - ret = -ENOMEM; 189 - goto err_unlock_rtnl; 190 - } 191 - 192 - ret = ethnl_phy_fill_reply(&req_info.base, rskb); 193 - if (ret) 194 - goto err_free_msg; 195 - 196 - rtnl_unlock(); 197 - ethnl_parse_header_dev_put(&req_info.base); 198 - genlmsg_end(rskb, reply_payload); 199 - 200 - return genlmsg_reply(rskb, info); 201 - 202 - err_free_msg: 203 - nlmsg_free(rskb); 204 - err_unlock_rtnl: 205 - rtnl_unlock(); 206 - ethnl_parse_header_dev_put(&req_info.base); 207 - return ret; 208 - } 209 - 210 - struct ethnl_phy_dump_ctx { 211 - struct phy_req_info *phy_req_info; 212 - }; 213 - 214 - int ethnl_phy_start(struct netlink_callback *cb) 215 - { 216 - const struct genl_dumpit_info *info = genl_dumpit_info(cb); 217 - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; 218 - struct nlattr **tb = info->info.attrs; 219 - int ret; 220 - 221 - BUILD_BUG_ON(sizeof(*ctx) > sizeof(cb->ctx)); 222 - 223 - ctx->phy_req_info = kzalloc(sizeof(*ctx->phy_req_info), GFP_KERNEL); 224 - if (!ctx->phy_req_info) 225 - return -ENOMEM; 226 - 227 - ret = ethnl_parse_header_dev_get(&ctx->phy_req_info->base, 228 - tb[ETHTOOL_A_PHY_HEADER], 229 - sock_net(cb->skb->sk), cb->extack, 230 - false); 231 - return ret; 232 - } 233 - 234 - int ethnl_phy_done(struct netlink_callback *cb) 235 - { 236 - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; 237 - 238 - kfree(ctx->phy_req_info); 239 - 240 - return 0; 241 - } 242 - 243 - static int ethnl_phy_dump_one_dev(struct sk_buff *skb, struct net_device *dev, 244 - struct netlink_callback *cb) 245 - { 246 - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; 247 - struct phy_req_info *pri = ctx->phy_req_info; 248 - struct phy_device_node *pdn; 249 - unsigned long index = 1; 250 - int ret = 0; 251 - void *ehdr; 252 - 253 - pri->base.dev = dev; 254 - 255 - xa_for_each(&dev->link_topo.phys, index, pdn) { 256 - ehdr = ethnl_dump_put(skb, cb, 257 - ETHTOOL_MSG_PHY_GET_REPLY); 258 - if (!ehdr) { 259 - ret = -EMSGSIZE; 260 - break; 261 - } 262 - 263 - ret = ethnl_fill_reply_header(skb, dev, 264 - ETHTOOL_A_PHY_HEADER); 265 - if (ret < 0) { 266 - genlmsg_cancel(skb, ehdr); 267 - break; 268 - } 269 - 270 - memcpy(&pri->pdn, pdn, sizeof(*pdn)); 271 - ret = ethnl_phy_fill_reply(&pri->base, skb); 272 - 273 - genlmsg_end(skb, ehdr); 274 - } 275 - 276 - return ret; 277 - } 278 - 279 - int ethnl_phy_dumpit(struct sk_buff *skb, struct netlink_callback *cb) 280 - { 281 - struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; 282 - struct net *net = sock_net(skb->sk); 283 - unsigned long ifindex = 1; 284 - struct net_device *dev; 285 - int ret = 0; 286 - 287 - rtnl_lock(); 288 - 289 - if (ctx->phy_req_info->base.dev) { 290 - ret = ethnl_phy_dump_one_dev(skb, ctx->phy_req_info->base.dev, cb); 291 - ethnl_parse_header_dev_put(&ctx->phy_req_info->base); 292 - ctx->phy_req_info->base.dev = NULL; 293 - } else { 294 - for_each_netdev_dump(net, dev, ifindex) { 295 - ret = ethnl_phy_dump_one_dev(skb, dev, cb); 296 - if (ret) 297 - break; 298 - } 299 - } 300 - rtnl_unlock(); 301 - 302 - if (ret == -EMSGSIZE && skb->len) 303 - return skb->len; 304 - return ret; 305 - } 306 -
+7 -6
net/ethtool/plca.c
··· 61 61 int ret; 62 62 63 63 // check that the PHY device is available and connected 64 - if (!req_base->phydev) { 64 + if (!dev->phydev) { 65 65 ret = -EOPNOTSUPP; 66 66 goto out; 67 67 } ··· 80 80 memset(&data->plca_cfg, 0xff, 81 81 sizeof_field(struct plca_reply_data, plca_cfg)); 82 82 83 - ret = ops->get_plca_cfg(req_base->phydev, &data->plca_cfg); 83 + ret = ops->get_plca_cfg(dev->phydev, &data->plca_cfg); 84 84 ethnl_ops_complete(dev); 85 85 86 86 out: ··· 141 141 static int 142 142 ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info) 143 143 { 144 + struct net_device *dev = req_info->dev; 144 145 const struct ethtool_phy_ops *ops; 145 146 struct nlattr **tb = info->attrs; 146 147 struct phy_plca_cfg plca_cfg; ··· 149 148 int ret; 150 149 151 150 // check that the PHY device is available and connected 152 - if (!req_info->phydev) 151 + if (!dev->phydev) 153 152 return -EOPNOTSUPP; 154 153 155 154 ops = ethtool_phy_ops; ··· 168 167 if (!mod) 169 168 return 0; 170 169 171 - ret = ops->set_plca_cfg(req_info->phydev, &plca_cfg, info->extack); 170 + ret = ops->set_plca_cfg(dev->phydev, &plca_cfg, info->extack); 172 171 return ret < 0 ? ret : 1; 173 172 } 174 173 ··· 204 203 int ret; 205 204 206 205 // check that the PHY device is available and connected 207 - if (!req_base->phydev) { 206 + if (!dev->phydev) { 208 207 ret = -EOPNOTSUPP; 209 208 goto out; 210 209 } ··· 223 222 memset(&data->plca_st, 0xff, 224 223 sizeof_field(struct plca_reply_data, plca_st)); 225 224 226 - ret = ops->get_plca_status(req_base->phydev, &data->plca_st); 225 + ret = ops->get_plca_status(dev->phydev, &data->plca_st); 227 226 ethnl_ops_complete(dev); 228 227 out: 229 228 return ret;
+6 -3
net/ethtool/pse-pd.c
··· 31 31 [ETHTOOL_A_PSE_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), 32 32 }; 33 33 34 - static int pse_get_pse_attributes(struct phy_device *phydev, 34 + static int pse_get_pse_attributes(struct net_device *dev, 35 35 struct netlink_ext_ack *extack, 36 36 struct pse_reply_data *data) 37 37 { 38 + struct phy_device *phydev = dev->phydev; 39 + 38 40 if (!phydev) { 39 41 NL_SET_ERR_MSG(extack, "No PHY is attached"); 40 42 return -EOPNOTSUPP; ··· 64 62 if (ret < 0) 65 63 return ret; 66 64 67 - ret = pse_get_pse_attributes(req_base->phydev, info->extack, data); 65 + ret = pse_get_pse_attributes(dev, info->extack, data); 68 66 69 67 ethnl_ops_complete(dev); 70 68 ··· 124 122 static int 125 123 ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info) 126 124 { 125 + struct net_device *dev = req_info->dev; 127 126 struct pse_control_config config = {}; 128 127 struct nlattr **tb = info->attrs; 129 128 struct phy_device *phydev; ··· 132 129 /* this values are already validated by the ethnl_pse_set_policy */ 133 130 config.admin_cotrol = nla_get_u32(tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]); 134 131 135 - phydev = req_info->phydev; 132 + phydev = dev->phydev; 136 133 if (!phydev) { 137 134 NL_SET_ERR_MSG(info->extack, "No PHY is attached"); 138 135 return -EOPNOTSUPP;
+7 -8
net/ethtool/strset.c
··· 233 233 } 234 234 235 235 static int strset_prepare_set(struct strset_info *info, struct net_device *dev, 236 - struct phy_device *phydev, unsigned int id, 237 - bool counts_only) 236 + unsigned int id, bool counts_only) 238 237 { 239 238 const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops; 240 239 const struct ethtool_ops *ops = dev->ethtool_ops; 241 240 void *strings; 242 241 int count, ret; 243 242 244 - if (id == ETH_SS_PHY_STATS && phydev && 243 + if (id == ETH_SS_PHY_STATS && dev->phydev && 245 244 !ops->get_ethtool_phy_stats && phy_ops && 246 245 phy_ops->get_sset_count) 247 - ret = phy_ops->get_sset_count(phydev); 246 + ret = phy_ops->get_sset_count(dev->phydev); 248 247 else if (ops->get_sset_count && ops->get_strings) 249 248 ret = ops->get_sset_count(dev, id); 250 249 else ··· 258 259 strings = kcalloc(count, ETH_GSTRING_LEN, GFP_KERNEL); 259 260 if (!strings) 260 261 return -ENOMEM; 261 - if (id == ETH_SS_PHY_STATS && phydev && 262 + if (id == ETH_SS_PHY_STATS && dev->phydev && 262 263 !ops->get_ethtool_phy_stats && phy_ops && 263 264 phy_ops->get_strings) 264 - phy_ops->get_strings(phydev, strings); 265 + phy_ops->get_strings(dev->phydev, strings); 265 266 else 266 267 ops->get_strings(dev, id, strings); 267 268 info->strings = strings; ··· 305 306 !data->sets[i].per_dev) 306 307 continue; 307 308 308 - ret = strset_prepare_set(&data->sets[i], dev, req_base->phydev, 309 - i, req_info->counts_only); 309 + ret = strset_prepare_set(&data->sets[i], dev, i, 310 + req_info->counts_only); 310 311 if (ret < 0) 311 312 goto err_ops; 312 313 }