Skip to content

Commit 425b0aa

Browse files
vladimirolteanNipaLocal
authored and
NipaLocal
committed
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 <[email protected]> Reviewed-by: Gerhard Engleder <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent ea8c8c8 commit 425b0aa

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,7 @@ int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
17291729
default:
17301730
return -ERANGE;
17311731
}
1732+
adapter->rx_tstamp_filter = rx_filter;
17321733
return 0;
17331734
}
17341735

@@ -3445,6 +3446,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
34453446
.ndo_change_mtu = lan743x_netdev_change_mtu,
34463447
.ndo_get_stats64 = lan743x_netdev_get_stats64,
34473448
.ndo_set_mac_address = lan743x_netdev_set_mac_address,
3449+
.ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get,
34483450
.ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
34493451
};
34503452

drivers/net/ethernet/microchip/lan743x_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ struct lan743x_adapter {
10871087
phy_interface_t phy_interface;
10881088
struct phylink *phylink;
10891089
struct phylink_config phylink_config;
1090+
int rx_tstamp_filter;
10901091
};
10911092

10921093
#define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))

drivers/net/ethernet/microchip/lan743x_ptp.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,24 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
17361736
lan743x_ptp_tx_ts_complete(adapter);
17371737
}
17381738

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+
17391757
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
17401758
struct kernel_hwtstamp_config *config,
17411759
struct netlink_ext_ack *extack)

drivers/net/ethernet/microchip/lan743x_ptp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter);
5151
void lan743x_ptp_close(struct lan743x_adapter *adapter);
5252
void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
5353
u32 link_speed);
54-
54+
int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
55+
struct kernel_hwtstamp_config *config);
5556
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
5657
struct kernel_hwtstamp_config *config,
5758
struct netlink_ext_ack *extack);

0 commit comments

Comments
 (0)