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

net: lan743x: implement ndo_hwtstamp_get()

Permit programs such as "hwtstamp_ctl -i eth0" to retrieve the current
timestamping configuration of the NIC, rather than returning "Device
driver does not have support for non-destructive SIOCGHWTSTAMP."

The driver configures all channels with the same timestamping settings.
On TX, retrieve the settings of the first channel, those should be
representative for the entire NIC. On RX, save the filter settings in a
new adapter field.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250514151931.1988047-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
abb258eb 958a857a

+23 -1
+2
drivers/net/ethernet/microchip/lan743x_main.c
··· 1729 1729 default: 1730 1730 return -ERANGE; 1731 1731 } 1732 + adapter->rx_tstamp_filter = rx_filter; 1732 1733 return 0; 1733 1734 } 1734 1735 ··· 3446 3445 .ndo_change_mtu = lan743x_netdev_change_mtu, 3447 3446 .ndo_get_stats64 = lan743x_netdev_get_stats64, 3448 3447 .ndo_set_mac_address = lan743x_netdev_set_mac_address, 3448 + .ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get, 3449 3449 .ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set, 3450 3450 }; 3451 3451
+1
drivers/net/ethernet/microchip/lan743x_main.h
··· 1087 1087 phy_interface_t phy_interface; 1088 1088 struct phylink *phylink; 1089 1089 struct phylink_config phylink_config; 1090 + int rx_tstamp_filter; 1090 1091 }; 1091 1092 1092 1093 #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
+18
drivers/net/ethernet/microchip/lan743x_ptp.c
··· 1736 1736 lan743x_ptp_tx_ts_complete(adapter); 1737 1737 } 1738 1738 1739 + int lan743x_ptp_hwtstamp_get(struct net_device *netdev, 1740 + struct kernel_hwtstamp_config *config) 1741 + { 1742 + struct lan743x_adapter *adapter = netdev_priv(netdev); 1743 + struct lan743x_tx *tx = &adapter->tx[0]; 1744 + 1745 + if (tx->ts_flags & TX_TS_FLAG_ONE_STEP_SYNC) 1746 + config->tx_type = HWTSTAMP_TX_ONESTEP_SYNC; 1747 + else if (tx->ts_flags & TX_TS_FLAG_TIMESTAMPING_ENABLED) 1748 + config->tx_type = HWTSTAMP_TX_ON; 1749 + else 1750 + config->tx_type = HWTSTAMP_TX_OFF; 1751 + 1752 + config->rx_filter = adapter->rx_tstamp_filter; 1753 + 1754 + return 0; 1755 + } 1756 + 1739 1757 int lan743x_ptp_hwtstamp_set(struct net_device *netdev, 1740 1758 struct kernel_hwtstamp_config *config, 1741 1759 struct netlink_ext_ack *extack)
+2 -1
drivers/net/ethernet/microchip/lan743x_ptp.h
··· 51 51 void lan743x_ptp_close(struct lan743x_adapter *adapter); 52 52 void lan743x_ptp_update_latency(struct lan743x_adapter *adapter, 53 53 u32 link_speed); 54 - 54 + int lan743x_ptp_hwtstamp_get(struct net_device *netdev, 55 + struct kernel_hwtstamp_config *config); 55 56 int lan743x_ptp_hwtstamp_set(struct net_device *netdev, 56 57 struct kernel_hwtstamp_config *config, 57 58 struct netlink_ext_ack *extack);