Skip to content

Commit

Permalink
net: ethernet: Add net_eth_get_ptp_clock_by_index() function
Browse files Browse the repository at this point in the history
This can be used to get the PTP clock if only network interface
index is known.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Jun 25, 2019
1 parent def6b14 commit 11b06fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/net/ethernet.h
Expand Up @@ -682,6 +682,26 @@ static inline struct device *net_eth_get_ptp_clock(struct net_if *iface)
}
#endif

/**
* @brief Return PTP clock that is tied to this ethernet network interface
* index.
*
* @param index Network interface index
*
* @return Pointer to PTP clock if found, NULL if not found or if this
* ethernet interface index does not support PTP.
*/
#if defined(CONFIG_PTP_CLOCK)
struct device *net_eth_get_ptp_clock_by_index(int index);
#else
static inline struct device *net_eth_get_ptp_clock_by_index(int index)
{
ARG_UNUSED(index);

return NULL;
}
#endif

/**
* @brief Return gPTP port number attached to this interface.
*
Expand Down
14 changes: 14 additions & 0 deletions subsys/net/l2/ethernet/ethernet.c
Expand Up @@ -987,6 +987,20 @@ struct device *net_eth_get_ptp_clock(struct net_if *iface)
}
#endif /* CONFIG_PTP_CLOCK */

#if defined(CONFIG_PTP_CLOCK)
struct device *net_eth_get_ptp_clock_by_index(int index)
{
struct net_if *iface;

iface = net_if_get_by_index(index);
if (!iface) {
return NULL;
}

return net_eth_get_ptp_clock(iface);
}
#endif

#if defined(CONFIG_NET_GPTP)
int net_eth_get_ptp_port(struct net_if *iface)
{
Expand Down

0 comments on commit 11b06fa

Please sign in to comment.