Skip to content

Commit

Permalink
ethtool: Add kernel API for PHC index
Browse files Browse the repository at this point in the history
Add a new function, which returns the physical clock index of a
networking device. This function will be used to get the physical clock
of a device for timestamp manipulation in the receive path.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
  • Loading branch information
Gerhard Engleder authored and intel-lab-lkp committed Mar 22, 2022
1 parent 27f1325 commit 1a1e2ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/linux/ethtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ void
ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
enum ethtool_link_mode_bit_indices link_mode);

/**
* ethtool_get_phc - Get phc index
* @dev: pointer to net_device structure
*
* Return index of phc
*/
int ethtool_get_phc(struct net_device *dev);

/**
* ethtool_get_phc_vclocks - Derive phc vclocks information, and caller
* is responsible to free memory of vclock_index
Expand Down
13 changes: 13 additions & 0 deletions net/ethtool/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,19 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
return 0;
}

int ethtool_get_phc(struct net_device *dev)
{
struct ethtool_ts_info info;
int ret;

ret = __ethtool_get_ts_info(dev, &info);
if (ret)
return ret;

return info.phc_index;
}
EXPORT_SYMBOL(ethtool_get_phc);

int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index)
{
struct ethtool_ts_info info = { };
Expand Down

0 comments on commit 1a1e2ad

Please sign in to comment.