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

net: partial revert of the "Make timestamping selectable: series

Revert following commits:

commit acec05fb78ab ("net_tstamp: Add TIMESTAMPING SOFTWARE and HARDWARE mask")
commit 11d55be06df0 ("net: ethtool: Add a command to expose current time stamping layer")
commit bb8645b00ced ("netlink: specs: Introduce new netlink command to get current timestamp")
commit d905f9c75329 ("net: ethtool: Add a command to list available time stamping layers")
commit aed5004ee7a0 ("netlink: specs: Introduce new netlink command to list available time stamping layers")
commit 51bdf3165f01 ("net: Replace hwtstamp_source by timestamping layer")
commit 0f7f463d4821 ("net: Change the API of PHY default timestamp to MAC")
commit 091fab122869 ("net: ethtool: ts: Update GET_TS to reply the current selected timestamp")
commit 152c75e1d002 ("net: ethtool: ts: Let the active time stamping layer be selectable")
commit ee60ea6be0d3 ("netlink: specs: Introduce time stamping set command")

They need more time for reviews.

Link: https://lore.kernel.org/all/20231118183529.6e67100c@kernel.org/
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+28 -566
-57
Documentation/netlink/specs/ethtool.yaml
··· 939 939 - 940 940 name: burst-tmr 941 941 type: u32 942 - - 943 - name: ts 944 - attributes: 945 - - 946 - name: header 947 - type: nest 948 - nested-attributes: header 949 - - 950 - name: ts-layer 951 - type: u32 952 - - 953 - name: ts-list 954 - attributes: 955 - - 956 - name: header 957 - type: nest 958 - nested-attributes: header 959 - - 960 - name: ts-list-layer 961 - type: binary 962 942 963 943 operations: 964 944 enum-model: directional ··· 1689 1709 name: mm-ntf 1690 1710 doc: Notification for change in MAC Merge configuration. 1691 1711 notify: mm-get 1692 - - 1693 - name: ts-get 1694 - doc: Get current timestamp 1695 - 1696 - attribute-set: ts 1697 - 1698 - do: 1699 - request: 1700 - attributes: 1701 - - header 1702 - reply: 1703 - attributes: &ts 1704 - - header 1705 - - ts-layer 1706 - - 1707 - name: ts-list-get 1708 - doc: Get list of timestamp devices available on an interface 1709 - 1710 - attribute-set: ts-list 1711 - 1712 - do: 1713 - request: 1714 - attributes: 1715 - - header 1716 - reply: 1717 - attributes: 1718 - - header 1719 - - ts-list-layer 1720 - - 1721 - name: ts-set 1722 - doc: Set the timestamp device 1723 - 1724 - attribute-set: ts 1725 - 1726 - do: 1727 - request: 1728 - attributes: *ts
-63
Documentation/networking/ethtool-netlink.rst
··· 225 225 ``ETHTOOL_MSG_RSS_GET`` get RSS settings 226 226 ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state 227 227 ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters 228 - ``ETHTOOL_MSG_TS_GET`` get current timestamping 229 - ``ETHTOOL_MSG_TS_LIST_GET`` list available timestampings 230 - ``ETHTOOL_MSG_TS_SET`` set current timestamping 231 228 ===================================== ================================= 232 229 233 230 Kernel to userspace: ··· 268 271 ``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters 269 272 ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings 270 273 ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status 271 - ``ETHTOOL_MSG_TS_GET_REPLY`` current timestamping 272 - ``ETHTOOL_MSG_TS_LIST_GET_REPLY`` available timestampings 273 274 ======================================== ================================= 274 275 275 276 ``GET`` requests are sent by userspace applications to retrieve device ··· 1994 1999 .. kernel-doc:: include/linux/ethtool.h 1995 2000 :identifiers: ethtool_mm_cfg 1996 2001 1997 - TS_GET 1998 - ====== 1999 - 2000 - Gets current timestamping. 2001 - 2002 - Request contents: 2003 - 2004 - ================================= ====== ==================== 2005 - ``ETHTOOL_A_TS_HEADER`` nested request header 2006 - ================================= ====== ==================== 2007 - 2008 - Kernel response contents: 2009 - 2010 - ======================= ====== ============================== 2011 - ``ETHTOOL_A_TS_HEADER`` nested reply header 2012 - ``ETHTOOL_A_TS_LAYER`` u32 current timestamping 2013 - ======================= ====== ============================== 2014 - 2015 - This command get the current timestamp layer. 2016 - 2017 - TS_LIST_GET 2018 - =========== 2019 - 2020 - Get the list of available timestampings. 2021 - 2022 - Request contents: 2023 - 2024 - ================================= ====== ==================== 2025 - ``ETHTOOL_A_TS_HEADER`` nested request header 2026 - ================================= ====== ==================== 2027 - 2028 - Kernel response contents: 2029 - 2030 - =========================== ====== ============================== 2031 - ``ETHTOOL_A_TS_HEADER`` nested reply header 2032 - ``ETHTOOL_A_TS_LIST_LAYER`` binary available timestampings 2033 - =========================== ====== ============================== 2034 - 2035 - This command lists all the possible timestamp layer available. 2036 - 2037 - TS_SET 2038 - ====== 2039 - 2040 - Modify the selected timestamping. 2041 - 2042 - Request contents: 2043 - 2044 - ======================= ====== =================== 2045 - ``ETHTOOL_A_TS_HEADER`` nested reply header 2046 - ``ETHTOOL_A_TS_LAYER`` u32 timestamping 2047 - ======================= ====== =================== 2048 - 2049 - This command set the timestamping with one that should be listed by the 2050 - TSLIST_GET command. 2051 - 2052 2002 Request translation 2053 2003 =================== 2054 2004 ··· 2100 2160 n/a ``ETHTOOL_MSG_PLCA_GET_STATUS`` 2101 2161 n/a ``ETHTOOL_MSG_MM_GET`` 2102 2162 n/a ``ETHTOOL_MSG_MM_SET`` 2103 - n/a ``ETHTOOL_MSG_TS_GET`` 2104 - n/a ``ETHTOOL_MSG_TS_LIST_GET`` 2105 - n/a ``ETHTOOL_MSG_TS_SET`` 2106 2163 =================================== =====================================
+3 -3
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
··· 470 470 struct lan966x_port *port = netdev_priv(dev); 471 471 int err; 472 472 473 - if (cfg->source != MAC_TIMESTAMPING && 474 - cfg->source != PHY_TIMESTAMPING) 473 + if (cfg->source != HWTSTAMP_SOURCE_NETDEV && 474 + cfg->source != HWTSTAMP_SOURCE_PHYLIB) 475 475 return -EOPNOTSUPP; 476 476 477 477 err = lan966x_ptp_setup_traps(port, cfg); 478 478 if (err) 479 479 return err; 480 480 481 - if (cfg->source == MAC_TIMESTAMPING) { 481 + if (cfg->source == HWTSTAMP_SOURCE_NETDEV) { 482 482 if (!port->lan966x->ptp) 483 483 return -EOPNOTSUPP; 484 484
-3
drivers/net/phy/bcm-phy-ptp.c
··· 931 931 return ERR_CAST(clock); 932 932 priv->ptp_clock = clock; 933 933 934 - /* Timestamp selected by default to keep legacy API */ 935 - phydev->default_timestamp = true; 936 - 937 934 priv->phydev = phydev; 938 935 bcm_ptp_init(priv); 939 936
-3
drivers/net/phy/dp83640.c
··· 1450 1450 phydev->mii_ts = &dp83640->mii_ts; 1451 1451 phydev->priv = dp83640; 1452 1452 1453 - /* Timestamp selected by default to keep legacy API */ 1454 - phydev->default_timestamp = true; 1455 - 1456 1453 spin_lock_init(&dp83640->rx_lock); 1457 1454 skb_queue_head_init(&dp83640->rx_queue); 1458 1455 skb_queue_head_init(&dp83640->tx_queue);
-6
drivers/net/phy/micrel.c
··· 3158 3158 ptp_priv->mii_ts.ts_info = lan8814_ts_info; 3159 3159 3160 3160 phydev->mii_ts = &ptp_priv->mii_ts; 3161 - 3162 - /* Timestamp selected by default to keep legacy API */ 3163 - phydev->default_timestamp = true; 3164 3161 } 3165 3162 3166 3163 static int lan8814_ptp_probe_once(struct phy_device *phydev) ··· 4585 4588 ptp_priv->mii_ts.ts_info = lan8841_ts_info; 4586 4589 4587 4590 phydev->mii_ts = &ptp_priv->mii_ts; 4588 - 4589 - /* Timestamp selected by default to keep legacy API */ 4590 - phydev->default_timestamp = true; 4591 4591 4592 4592 return 0; 4593 4593 }
-2
drivers/net/phy/mscc/mscc_ptp.c
··· 1570 1570 return PTR_ERR(vsc8531->load_save); 1571 1571 } 1572 1572 1573 - /* Timestamp selected by default to keep legacy API */ 1574 - phydev->default_timestamp = true; 1575 1573 vsc8531->ptp->phydev = phydev; 1576 1574 1577 1575 return 0;
-3
drivers/net/phy/nxp-c45-tja11xx.c
··· 1658 1658 priv->mii_ts.ts_info = nxp_c45_ts_info; 1659 1659 phydev->mii_ts = &priv->mii_ts; 1660 1660 ret = nxp_c45_init_ptp_clock(priv); 1661 - 1662 - /* Timestamp selected by default to keep legacy API */ 1663 - phydev->default_timestamp = true; 1664 1661 } else { 1665 1662 phydev_dbg(phydev, "PTP support not enabled even if the phy supports it"); 1666 1663 }
-37
drivers/net/phy/phy_device.c
··· 1412 1412 EXPORT_SYMBOL(phy_sfp_probe); 1413 1413 1414 1414 /** 1415 - * phy_set_timestamp - set the default selected timestamping device 1416 - * @dev: Pointer to net_device 1417 - * @phydev: Pointer to phy_device 1418 - * 1419 - * This is used to set default timestamping device taking into account 1420 - * the new API choice, which is selecting the timestamping from MAC by 1421 - * default if the phydev does not have default_timestamp flag enabled. 1422 - */ 1423 - static void phy_set_timestamp(struct net_device *dev, struct phy_device *phydev) 1424 - { 1425 - const struct ethtool_ops *ops = dev->ethtool_ops; 1426 - 1427 - if (!phy_has_tsinfo(phydev)) 1428 - return; 1429 - 1430 - if (!ops->get_ts_info || phydev->default_timestamp) 1431 - dev->ts_layer = PHY_TIMESTAMPING; 1432 - } 1433 - 1434 - /** 1435 1415 * phy_attach_direct - attach a network device to a given PHY device pointer 1436 1416 * @dev: network device to attach 1437 1417 * @phydev: Pointer to phy_device to attach ··· 1484 1504 1485 1505 phydev->phy_link_change = phy_link_change; 1486 1506 if (dev) { 1487 - phy_set_timestamp(dev, phydev); 1488 1507 phydev->attached_dev = dev; 1489 1508 dev->phydev = phydev; 1490 1509 ··· 1812 1833 1813 1834 phy_suspend(phydev); 1814 1835 if (dev) { 1815 - const struct ethtool_ops *ops = dev->ethtool_ops; 1816 - struct ethtool_ts_info ts_info = {0}; 1817 - 1818 - if (ops->get_ts_info) { 1819 - ops->get_ts_info(dev, &ts_info); 1820 - if ((ts_info.so_timestamping & 1821 - SOF_TIMESTAMPING_HARDWARE_MASK) == 1822 - SOF_TIMESTAMPING_HARDWARE_MASK) 1823 - dev->ts_layer = MAC_TIMESTAMPING; 1824 - else if ((ts_info.so_timestamping & 1825 - SOF_TIMESTAMPING_SOFTWARE_MASK) == 1826 - SOF_TIMESTAMPING_SOFTWARE_MASK) 1827 - dev->ts_layer = SOFTWARE_TIMESTAMPING; 1828 - } else { 1829 - dev->ts_layer = NO_TIMESTAMPING; 1830 - } 1831 1836 phydev->attached_dev->phydev = NULL; 1832 1837 phydev->attached_dev = NULL; 1833 1838 }
+8 -3
include/linux/net_tstamp.h
··· 5 5 6 6 #include <uapi/linux/net_tstamp.h> 7 7 8 + enum hwtstamp_source { 9 + HWTSTAMP_SOURCE_NETDEV, 10 + HWTSTAMP_SOURCE_PHYLIB, 11 + }; 12 + 8 13 /** 9 14 * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config 10 15 * ··· 20 15 * a legacy implementation of a lower driver 21 16 * @copied_to_user: request was passed to a legacy implementation which already 22 17 * copied the ioctl request back to user space 23 - * @source: indication whether timestamps should come from software, the netdev 24 - * or from an attached phylib PHY 18 + * @source: indication whether timestamps should come from the netdev or from 19 + * an attached phylib PHY 25 20 * 26 21 * Prefer using this structure for in-kernel processing of hardware 27 22 * timestamping configuration, over the inextensible struct hwtstamp_config ··· 33 28 int rx_filter; 34 29 struct ifreq *ifr; 35 30 bool copied_to_user; 36 - enum timestamping_layer source; 31 + enum hwtstamp_source source; 37 32 }; 38 33 39 34 static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
-5
include/linux/netdevice.h
··· 47 47 #include <uapi/linux/if_bonding.h> 48 48 #include <uapi/linux/pkt_cls.h> 49 49 #include <uapi/linux/netdev.h> 50 - #include <uapi/linux/net_tstamp.h> 51 50 #include <linux/hashtable.h> 52 51 #include <linux/rbtree.h> 53 52 #include <net/net_trackers.h> ··· 2074 2075 * 2075 2076 * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, 2076 2077 * where the clock is recovered. 2077 - * @ts_layer: Tracks which network device 2078 - * performs packet time stamping. 2079 2078 * 2080 2079 * FIXME: cleanup struct net_device such that network protocol info 2081 2080 * moves out. ··· 2435 2438 #if IS_ENABLED(CONFIG_DPLL) 2436 2439 struct dpll_pin *dpll_pin; 2437 2440 #endif 2438 - 2439 - enum timestamping_layer ts_layer; 2440 2441 }; 2441 2442 #define to_net_dev(d) container_of(d, struct net_device, dev) 2442 2443
-4
include/linux/phy.h
··· 604 604 * handling shall be postponed until PHY has resumed 605 605 * @irq_rerun: Flag indicating interrupts occurred while PHY was suspended, 606 606 * requiring a rerun of the interrupt handler after resume 607 - * @default_timestamp: Flag indicating whether we are using the phy 608 - * timestamp as the default one 609 607 * @interface: enum phy_interface_t value 610 608 * @skb: Netlink message for cable diagnostics 611 609 * @nest: Netlink nest used for cable diagnostics ··· 666 668 unsigned interrupts:1; 667 669 unsigned irq_suspended:1; 668 670 unsigned irq_rerun:1; 669 - 670 - unsigned default_timestamp:1; 671 671 672 672 int rate_matching; 673 673
-29
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_TS_GET, 61 - ETHTOOL_MSG_TS_LIST_GET, 62 - ETHTOOL_MSG_TS_SET, 63 60 64 61 /* add new constants above here */ 65 62 __ETHTOOL_MSG_USER_CNT, ··· 109 112 ETHTOOL_MSG_PLCA_NTF, 110 113 ETHTOOL_MSG_MM_GET_REPLY, 111 114 ETHTOOL_MSG_MM_NTF, 112 - ETHTOOL_MSG_TS_GET_REPLY, 113 - ETHTOOL_MSG_TS_LIST_GET_REPLY, 114 115 115 116 /* add new constants above here */ 116 117 __ETHTOOL_MSG_KERNEL_CNT, ··· 973 978 /* add new constants above here */ 974 979 __ETHTOOL_A_MM_CNT, 975 980 ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) 976 - }; 977 - 978 - /* TS LAYER */ 979 - 980 - enum { 981 - ETHTOOL_A_TS_UNSPEC, 982 - ETHTOOL_A_TS_HEADER, /* nest - _A_HEADER_* */ 983 - ETHTOOL_A_TS_LAYER, /* u32 */ 984 - 985 - /* add new constants above here */ 986 - __ETHTOOL_A_TS_CNT, 987 - ETHTOOL_A_TS_MAX = (__ETHTOOL_A_TS_CNT - 1) 988 - }; 989 - 990 - /* TS LIST LAYER */ 991 - 992 - enum { 993 - ETHTOOL_A_TS_LIST_UNSPEC, 994 - ETHTOOL_A_TS_LIST_HEADER, /* nest - _A_HEADER_* */ 995 - ETHTOOL_A_TS_LIST_LAYER, /* array, u32 */ 996 - 997 - /* add new constants above here */ 998 - __ETHTOOL_A_TS_LIST_CNT, 999 - ETHTOOL_A_TS_LIST_MAX = (__ETHTOOL_A_TS_LIST_CNT - 1) 1000 981 }; 1001 982 1002 983 /* generic netlink info */
-18
include/uapi/linux/net_tstamp.h
··· 13 13 #include <linux/types.h> 14 14 #include <linux/socket.h> /* for SO_TIMESTAMPING */ 15 15 16 - /* Layer of the TIMESTAMPING provider */ 17 - enum timestamping_layer { 18 - NO_TIMESTAMPING, 19 - SOFTWARE_TIMESTAMPING, 20 - MAC_TIMESTAMPING, 21 - PHY_TIMESTAMPING, 22 - 23 - __TIMESTAMPING_COUNT, 24 - }; 25 - 26 16 /* SO_TIMESTAMPING flags */ 27 17 enum { 28 18 SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), ··· 47 57 SOF_TIMESTAMPING_TX_SOFTWARE | \ 48 58 SOF_TIMESTAMPING_TX_SCHED | \ 49 59 SOF_TIMESTAMPING_TX_ACK) 50 - 51 - #define SOF_TIMESTAMPING_SOFTWARE_MASK (SOF_TIMESTAMPING_RX_SOFTWARE | \ 52 - SOF_TIMESTAMPING_TX_SOFTWARE | \ 53 - SOF_TIMESTAMPING_SOFTWARE) 54 - 55 - #define SOF_TIMESTAMPING_HARDWARE_MASK (SOF_TIMESTAMPING_RX_HARDWARE | \ 56 - SOF_TIMESTAMPING_TX_HARDWARE | \ 57 - SOF_TIMESTAMPING_RAW_HARDWARE) 58 60 59 61 /** 60 62 * struct so_timestamping - SO_TIMESTAMPING parameter
-3
net/core/dev.c
··· 10212 10212 dev->rtnl_link_state == RTNL_LINK_INITIALIZED) 10213 10213 rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL, 0, NULL); 10214 10214 10215 - if (dev->ethtool_ops->get_ts_info) 10216 - dev->ts_layer = MAC_TIMESTAMPING; 10217 - 10218 10215 out: 10219 10216 return ret; 10220 10217
+14 -22
net/core/dev_ioctl.c
··· 259 259 * @dev: Network device 260 260 * @cfg: Timestamping configuration structure 261 261 * 262 - * Helper for calling the selected hardware provider timestamping. 262 + * Helper for enforcing a common policy that phylib timestamping, if available, 263 + * should take precedence in front of hardware timestamping provided by the 264 + * netdev. 263 265 * 264 266 * Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), and 265 267 * there only exists a phydev->mii_ts->hwtstamp() method. So this will return ··· 271 269 static int dev_get_hwtstamp_phylib(struct net_device *dev, 272 270 struct kernel_hwtstamp_config *cfg) 273 271 { 274 - enum timestamping_layer ts_layer = dev->ts_layer; 275 - 276 - if (ts_layer == PHY_TIMESTAMPING) 272 + if (phy_has_hwtstamp(dev->phydev)) 277 273 return phy_hwtstamp_get(dev->phydev, cfg); 278 - else if (ts_layer == MAC_TIMESTAMPING) 279 - return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg); 280 274 281 - return -EOPNOTSUPP; 275 + return dev->netdev_ops->ndo_hwtstamp_get(dev, cfg); 282 276 } 283 277 284 278 static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) ··· 315 317 * @cfg: Timestamping configuration structure 316 318 * @extack: Netlink extended ack message structure, for error reporting 317 319 * 318 - * Helper for calling the selected hardware provider timestamping. 319 - * If the netdev driver needs to perform specific actions even for PHY 320 + * Helper for enforcing a common policy that phylib timestamping, if available, 321 + * should take precedence in front of hardware timestamping provided by the 322 + * netdev. If the netdev driver needs to perform specific actions even for PHY 320 323 * timestamping to work properly (a switch port must trap the timestamped 321 324 * frames and not forward them), it must set IFF_SEE_ALL_HWTSTAMP_REQUESTS in 322 325 * dev->priv_flags. ··· 327 328 struct netlink_ext_ack *extack) 328 329 { 329 330 const struct net_device_ops *ops = dev->netdev_ops; 330 - enum timestamping_layer ts_layer = dev->ts_layer; 331 + bool phy_ts = phy_has_hwtstamp(dev->phydev); 331 332 struct kernel_hwtstamp_config old_cfg = {}; 332 333 bool changed = false; 333 334 int err; 334 335 335 - cfg->source = ts_layer; 336 + cfg->source = phy_ts ? HWTSTAMP_SOURCE_PHYLIB : HWTSTAMP_SOURCE_NETDEV; 336 337 337 - if (ts_layer != PHY_TIMESTAMPING && 338 - ts_layer != MAC_TIMESTAMPING) 339 - return -EOPNOTSUPP; 340 - 341 - if (ts_layer == PHY_TIMESTAMPING && 342 - dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) { 338 + if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { 343 339 err = ops->ndo_hwtstamp_get(dev, &old_cfg); 344 340 if (err) 345 341 return err; 346 342 } 347 343 348 - if (ts_layer == MAC_TIMESTAMPING || 349 - dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) { 344 + if (!phy_ts || (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) { 350 345 err = ops->ndo_hwtstamp_set(dev, cfg, extack); 351 346 if (err) { 352 347 if (extack->_msg) ··· 349 356 } 350 357 } 351 358 352 - if (ts_layer == PHY_TIMESTAMPING && 353 - dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS) 359 + if (phy_ts && (dev->priv_flags & IFF_SEE_ALL_HWTSTAMP_REQUESTS)) 354 360 changed = kernel_hwtstamp_config_changed(&old_cfg, cfg); 355 361 356 - if (ts_layer == PHY_TIMESTAMPING) { 362 + if (phy_ts) { 357 363 err = phy_hwtstamp_set(dev->phydev, cfg, extack); 358 364 if (err) { 359 365 if (changed)
-10
net/core/timestamping.c
··· 21 21 22 22 void skb_clone_tx_timestamp(struct sk_buff *skb) 23 23 { 24 - enum timestamping_layer ts_layer; 25 24 struct mii_timestamper *mii_ts; 26 25 struct sk_buff *clone; 27 26 unsigned int type; 28 27 29 28 if (!skb->sk) 30 - return; 31 - 32 - ts_layer = skb->dev->ts_layer; 33 - if (ts_layer != PHY_TIMESTAMPING) 34 29 return; 35 30 36 31 type = classify(skb); ··· 44 49 45 50 bool skb_defer_rx_timestamp(struct sk_buff *skb) 46 51 { 47 - enum timestamping_layer ts_layer; 48 52 struct mii_timestamper *mii_ts; 49 53 unsigned int type; 50 54 51 55 if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts) 52 - return false; 53 - 54 - ts_layer = skb->dev->ts_layer; 55 - if (ts_layer != PHY_TIMESTAMPING) 56 56 return false; 57 57 58 58 if (skb_headroom(skb) < ETH_HLEN)
+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 ts.o 11 + module.o pse-pd.o plca.o mm.o
+2 -17
net/ethtool/common.c
··· 633 633 { 634 634 const struct ethtool_ops *ops = dev->ethtool_ops; 635 635 struct phy_device *phydev = dev->phydev; 636 - enum timestamping_layer ts_layer; 637 - int ret; 638 636 639 637 memset(info, 0, sizeof(*info)); 640 638 info->cmd = ETHTOOL_GET_TS_INFO; 641 639 642 - ts_layer = dev->ts_layer; 643 - if (ts_layer == SOFTWARE_TIMESTAMPING) { 644 - ret = ops->get_ts_info(dev, info); 645 - if (ret) 646 - return ret; 647 - info->so_timestamping &= ~SOF_TIMESTAMPING_HARDWARE_MASK; 648 - info->phc_index = -1; 649 - info->rx_filters = 0; 650 - info->tx_types = 0; 651 - return 0; 652 - } 653 - 654 - if (ts_layer == PHY_TIMESTAMPING) 640 + if (phy_has_tsinfo(phydev)) 655 641 return phy_ts_info(phydev, info); 656 - 657 - if (ts_layer == MAC_TIMESTAMPING) 642 + if (ops->get_ts_info) 658 643 return ops->get_ts_info(dev, info); 659 644 660 645 info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
-1
net/ethtool/common.h
··· 35 35 extern const char sof_timestamping_names[][ETH_GSTRING_LEN]; 36 36 extern const char ts_tx_type_names[][ETH_GSTRING_LEN]; 37 37 extern const char ts_rx_filter_names[][ETH_GSTRING_LEN]; 38 - extern const char ts_layer_names[][ETH_GSTRING_LEN]; 39 38 extern const char udp_tunnel_type_names[][ETH_GSTRING_LEN]; 40 39 41 40 int __ethtool_get_link(struct net_device *dev);
-28
net/ethtool/netlink.c
··· 306 306 [ETHTOOL_MSG_PLCA_GET_STATUS] = &ethnl_plca_status_request_ops, 307 307 [ETHTOOL_MSG_MM_GET] = &ethnl_mm_request_ops, 308 308 [ETHTOOL_MSG_MM_SET] = &ethnl_mm_request_ops, 309 - [ETHTOOL_MSG_TS_GET] = &ethnl_ts_request_ops, 310 - [ETHTOOL_MSG_TS_LIST_GET] = &ethnl_ts_list_request_ops, 311 - [ETHTOOL_MSG_TS_SET] = &ethnl_ts_request_ops, 312 309 }; 313 310 314 311 static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) ··· 1127 1130 .doit = ethnl_default_set_doit, 1128 1131 .policy = ethnl_mm_set_policy, 1129 1132 .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, 1130 - }, 1131 - { 1132 - .cmd = ETHTOOL_MSG_TS_GET, 1133 - .doit = ethnl_default_doit, 1134 - .start = ethnl_default_start, 1135 - .dumpit = ethnl_default_dumpit, 1136 - .done = ethnl_default_done, 1137 - .policy = ethnl_ts_get_policy, 1138 - .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, 1139 - }, 1140 - { 1141 - .cmd = ETHTOOL_MSG_TS_LIST_GET, 1142 - .doit = ethnl_default_doit, 1143 - .start = ethnl_default_start, 1144 - .dumpit = ethnl_default_dumpit, 1145 - .done = ethnl_default_done, 1146 - .policy = ethnl_ts_get_policy, 1147 - .maxattr = ARRAY_SIZE(ethnl_ts_get_policy) - 1, 1148 - }, 1149 - { 1150 - .cmd = ETHTOOL_MSG_TS_SET, 1151 - .flags = GENL_UNS_ADMIN_PERM, 1152 - .doit = ethnl_default_set_doit, 1153 - .policy = ethnl_ts_set_policy, 1154 - .maxattr = ARRAY_SIZE(ethnl_ts_set_policy) - 1, 1155 1133 }, 1156 1134 }; 1157 1135
-4
net/ethtool/netlink.h
··· 395 395 extern const struct ethnl_request_ops ethnl_plca_cfg_request_ops; 396 396 extern const struct ethnl_request_ops ethnl_plca_status_request_ops; 397 397 extern const struct ethnl_request_ops ethnl_mm_request_ops; 398 - extern const struct ethnl_request_ops ethnl_ts_request_ops; 399 - extern const struct ethnl_request_ops ethnl_ts_list_request_ops; 400 398 401 399 extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; 402 400 extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; ··· 441 443 extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; 442 444 extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; 443 445 extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; 444 - extern const struct nla_policy ethnl_ts_get_policy[ETHTOOL_A_TS_HEADER + 1]; 445 - extern const struct nla_policy ethnl_ts_set_policy[ETHTOOL_A_TS_MAX + 1]; 446 446 447 447 int ethnl_set_features(struct sk_buff *skb, struct genl_info *info); 448 448 int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info);
-244
net/ethtool/ts.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - 3 - #include <linux/net_tstamp.h> 4 - #include <linux/phy.h> 5 - 6 - #include "netlink.h" 7 - #include "common.h" 8 - #include "bitset.h" 9 - 10 - struct ts_req_info { 11 - struct ethnl_req_info base; 12 - }; 13 - 14 - struct ts_reply_data { 15 - struct ethnl_reply_data base; 16 - enum timestamping_layer ts_layer; 17 - }; 18 - 19 - #define TS_REPDATA(__reply_base) \ 20 - container_of(__reply_base, struct ts_reply_data, base) 21 - 22 - /* TS_GET */ 23 - const struct nla_policy ethnl_ts_get_policy[] = { 24 - [ETHTOOL_A_TS_HEADER] = 25 - NLA_POLICY_NESTED(ethnl_header_policy), 26 - }; 27 - 28 - static int ts_prepare_data(const struct ethnl_req_info *req_base, 29 - struct ethnl_reply_data *reply_base, 30 - const struct genl_info *info) 31 - { 32 - struct ts_reply_data *data = TS_REPDATA(reply_base); 33 - struct net_device *dev = reply_base->dev; 34 - int ret; 35 - 36 - ret = ethnl_ops_begin(dev); 37 - if (ret < 0) 38 - return ret; 39 - 40 - data->ts_layer = dev->ts_layer; 41 - 42 - ethnl_ops_complete(dev); 43 - 44 - return ret; 45 - } 46 - 47 - static int ts_reply_size(const struct ethnl_req_info *req_base, 48 - const struct ethnl_reply_data *reply_base) 49 - { 50 - return nla_total_size(sizeof(u32)); 51 - } 52 - 53 - static int ts_fill_reply(struct sk_buff *skb, 54 - const struct ethnl_req_info *req_base, 55 - const struct ethnl_reply_data *reply_base) 56 - { 57 - struct ts_reply_data *data = TS_REPDATA(reply_base); 58 - 59 - return nla_put_u32(skb, ETHTOOL_A_TS_LAYER, data->ts_layer); 60 - } 61 - 62 - /* TS_SET */ 63 - const struct nla_policy ethnl_ts_set_policy[] = { 64 - [ETHTOOL_A_TS_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), 65 - [ETHTOOL_A_TS_LAYER] = NLA_POLICY_RANGE(NLA_U32, 0, 66 - __TIMESTAMPING_COUNT - 1) 67 - }; 68 - 69 - static int ethnl_set_ts_validate(struct ethnl_req_info *req_info, 70 - struct genl_info *info) 71 - { 72 - struct nlattr **tb = info->attrs; 73 - const struct net_device_ops *ops = req_info->dev->netdev_ops; 74 - 75 - if (!ops->ndo_hwtstamp_set) 76 - return -EOPNOTSUPP; 77 - 78 - if (!tb[ETHTOOL_A_TS_LAYER]) 79 - return 0; 80 - 81 - return 1; 82 - } 83 - 84 - static int ethnl_set_ts(struct ethnl_req_info *req_info, struct genl_info *info) 85 - { 86 - struct net_device *dev = req_info->dev; 87 - const struct ethtool_ops *ops = dev->ethtool_ops; 88 - struct kernel_hwtstamp_config config = {0}; 89 - struct nlattr **tb = info->attrs; 90 - enum timestamping_layer ts_layer; 91 - bool mod = false; 92 - int ret; 93 - 94 - ts_layer = dev->ts_layer; 95 - ethnl_update_u32(&ts_layer, tb[ETHTOOL_A_TS_LAYER], &mod); 96 - 97 - if (!mod) 98 - return 0; 99 - 100 - if (ts_layer == SOFTWARE_TIMESTAMPING) { 101 - struct ethtool_ts_info ts_info = {0}; 102 - 103 - if (!ops->get_ts_info) { 104 - NL_SET_ERR_MSG_ATTR(info->extack, 105 - tb[ETHTOOL_A_TS_LAYER], 106 - "this net device cannot support timestamping"); 107 - return -EINVAL; 108 - } 109 - 110 - ops->get_ts_info(dev, &ts_info); 111 - if ((ts_info.so_timestamping & 112 - SOF_TIMESTAMPING_SOFTWARE_MASK) != 113 - SOF_TIMESTAMPING_SOFTWARE_MASK) { 114 - NL_SET_ERR_MSG_ATTR(info->extack, 115 - tb[ETHTOOL_A_TS_LAYER], 116 - "this net device cannot support software timestamping"); 117 - return -EINVAL; 118 - } 119 - } else if (ts_layer == MAC_TIMESTAMPING) { 120 - struct ethtool_ts_info ts_info = {0}; 121 - 122 - if (!ops->get_ts_info) { 123 - NL_SET_ERR_MSG_ATTR(info->extack, 124 - tb[ETHTOOL_A_TS_LAYER], 125 - "this net device cannot support timestamping"); 126 - return -EINVAL; 127 - } 128 - 129 - ops->get_ts_info(dev, &ts_info); 130 - if ((ts_info.so_timestamping & 131 - SOF_TIMESTAMPING_HARDWARE_MASK) != 132 - SOF_TIMESTAMPING_HARDWARE_MASK) { 133 - NL_SET_ERR_MSG_ATTR(info->extack, 134 - tb[ETHTOOL_A_TS_LAYER], 135 - "this net device cannot support hardware timestamping"); 136 - return -EINVAL; 137 - } 138 - } else if (ts_layer == PHY_TIMESTAMPING && !phy_has_tsinfo(dev->phydev)) { 139 - NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_TS_LAYER], 140 - "this phy device cannot support timestamping"); 141 - return -EINVAL; 142 - } 143 - 144 - /* Disable time stamping in the current layer. */ 145 - if (netif_device_present(dev) && 146 - (dev->ts_layer == PHY_TIMESTAMPING || 147 - dev->ts_layer == MAC_TIMESTAMPING)) { 148 - ret = dev_set_hwtstamp_phylib(dev, &config, info->extack); 149 - if (ret < 0) 150 - return ret; 151 - } 152 - 153 - dev->ts_layer = ts_layer; 154 - 155 - return 1; 156 - } 157 - 158 - const struct ethnl_request_ops ethnl_ts_request_ops = { 159 - .request_cmd = ETHTOOL_MSG_TS_GET, 160 - .reply_cmd = ETHTOOL_MSG_TS_GET_REPLY, 161 - .hdr_attr = ETHTOOL_A_TS_HEADER, 162 - .req_info_size = sizeof(struct ts_req_info), 163 - .reply_data_size = sizeof(struct ts_reply_data), 164 - 165 - .prepare_data = ts_prepare_data, 166 - .reply_size = ts_reply_size, 167 - .fill_reply = ts_fill_reply, 168 - 169 - .set_validate = ethnl_set_ts_validate, 170 - .set = ethnl_set_ts, 171 - }; 172 - 173 - /* TS_LIST_GET */ 174 - struct ts_list_reply_data { 175 - struct ethnl_reply_data base; 176 - enum timestamping_layer ts_layer[__TIMESTAMPING_COUNT]; 177 - u8 num_ts; 178 - }; 179 - 180 - #define TS_LIST_REPDATA(__reply_base) \ 181 - container_of(__reply_base, struct ts_list_reply_data, base) 182 - 183 - static int ts_list_prepare_data(const struct ethnl_req_info *req_base, 184 - struct ethnl_reply_data *reply_base, 185 - const struct genl_info *info) 186 - { 187 - struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); 188 - struct net_device *dev = reply_base->dev; 189 - const struct ethtool_ops *ops = dev->ethtool_ops; 190 - int ret, i = 0; 191 - 192 - ret = ethnl_ops_begin(dev); 193 - if (ret < 0) 194 - return ret; 195 - 196 - if (phy_has_tsinfo(dev->phydev)) 197 - data->ts_layer[i++] = PHY_TIMESTAMPING; 198 - if (ops->get_ts_info) { 199 - struct ethtool_ts_info ts_info = {0}; 200 - 201 - ops->get_ts_info(dev, &ts_info); 202 - if (ts_info.so_timestamping & 203 - SOF_TIMESTAMPING_HARDWARE_MASK) 204 - data->ts_layer[i++] = MAC_TIMESTAMPING; 205 - 206 - if (ts_info.so_timestamping & 207 - SOF_TIMESTAMPING_SOFTWARE_MASK) 208 - data->ts_layer[i++] = SOFTWARE_TIMESTAMPING; 209 - } 210 - 211 - data->num_ts = i; 212 - ethnl_ops_complete(dev); 213 - 214 - return ret; 215 - } 216 - 217 - static int ts_list_reply_size(const struct ethnl_req_info *req_base, 218 - const struct ethnl_reply_data *reply_base) 219 - { 220 - struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); 221 - 222 - return nla_total_size(sizeof(u32)) * data->num_ts; 223 - } 224 - 225 - static int ts_list_fill_reply(struct sk_buff *skb, 226 - const struct ethnl_req_info *req_base, 227 - const struct ethnl_reply_data *reply_base) 228 - { 229 - struct ts_list_reply_data *data = TS_LIST_REPDATA(reply_base); 230 - 231 - return nla_put(skb, ETHTOOL_A_TS_LIST_LAYER, sizeof(u32) * data->num_ts, data->ts_layer); 232 - } 233 - 234 - const struct ethnl_request_ops ethnl_ts_list_request_ops = { 235 - .request_cmd = ETHTOOL_MSG_TS_LIST_GET, 236 - .reply_cmd = ETHTOOL_MSG_TS_LIST_GET_REPLY, 237 - .hdr_attr = ETHTOOL_A_TS_HEADER, 238 - .req_info_size = sizeof(struct ts_req_info), 239 - .reply_data_size = sizeof(struct ts_list_reply_data), 240 - 241 - .prepare_data = ts_list_prepare_data, 242 - .reply_size = ts_list_reply_size, 243 - .fill_reply = ts_list_fill_reply, 244 - };