Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions drivers/net/phy/bcm-phy-ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,18 @@ static void bcm_ptp_txtstamp(struct mii_timestamper *mii_ts,
kfree_skb(skb);
}

static int bcm_ptp_hwtstamp_get(struct mii_timestamper *mii_ts,
struct kernel_hwtstamp_config *cfg)
{
struct bcm_ptp_private *priv = mii2priv(mii_ts);

cfg->rx_filter = priv->hwts_rx ? HWTSTAMP_FILTER_PTP_V2_EVENT
: HWTSTAMP_FILTER_NONE;
cfg->tx_type = priv->tx_type;

return 0;
}

static int bcm_ptp_hwtstamp(struct mii_timestamper *mii_ts,
struct kernel_hwtstamp_config *cfg,
struct netlink_ext_ack *extack)
Expand Down Expand Up @@ -899,6 +911,7 @@ static void bcm_ptp_init(struct bcm_ptp_private *priv)
priv->mii_ts.rxtstamp = bcm_ptp_rxtstamp;
priv->mii_ts.txtstamp = bcm_ptp_txtstamp;
priv->mii_ts.hwtstamp = bcm_ptp_hwtstamp;
priv->mii_ts.hwtstamp_get = bcm_ptp_hwtstamp_get;
priv->mii_ts.ts_info = bcm_ptp_ts_info;

priv->phydev->mii_ts = &priv->mii_ts;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ int __phy_hwtstamp_get(struct phy_device *phydev,
if (!phydev)
return -ENODEV;

if (phydev->mii_ts && phydev->mii_ts->hwtstamp_get)
return phydev->mii_ts->hwtstamp_get(phydev->mii_ts, config);

return -EOPNOTSUPP;
}

Expand Down
5 changes: 5 additions & 0 deletions include/linux/mii_timestamper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct phy_device;
*
* @hwtstamp: Handles SIOCSHWTSTAMP ioctl for hardware time stamping.
*
* @hwtstamp_get: Handles SIOCGHWTSTAMP ioctl for hardware time stamping.
*
* @link_state: Allows the device to respond to changes in the link
* state. The caller invokes this function while holding
* the phy_device mutex.
Expand All @@ -55,6 +57,9 @@ struct mii_timestamper {
struct kernel_hwtstamp_config *kernel_config,
struct netlink_ext_ack *extack);

int (*hwtstamp_get)(struct mii_timestamper *mii_ts,
struct kernel_hwtstamp_config *kernel_config);

void (*link_state)(struct mii_timestamper *mii_ts,
struct phy_device *phydev);

Expand Down
9 changes: 5 additions & 4 deletions net/core/dev_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg)
*
* Helper for calling the default hardware provider timestamping.
*
* Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), and
* there only exists a phydev->mii_ts->hwtstamp() method. So this will return
* -EOPNOTSUPP for phylib for now, which is still more accurate than letting
* the netdev handle the GET request.
* Note: phy_mii_ioctl() only handles SIOCSHWTSTAMP (not SIOCGHWTSTAMP), but
* phydev->mii_ts has both hwtstamp_get() and hwtstamp_set() methods. So this
* will return -EOPNOTSUPP for phylib only if hwtstamp_get() is not
* implemented for now, which is still more accurate than letting the netdev
* handle the GET request.
*/
int dev_get_hwtstamp_phylib(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
Expand Down
Loading