Skip to content
Permalink
Browse files

net: ethernet: Add net_eth_get_ptp_clock_by_index() function

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 May 24, 2019
1 parent def6b14 commit 11b06fab761892f15a955aca864193bc9b31498c
Showing with 34 additions and 0 deletions.
  1. +20 −0 include/net/ethernet.h
  2. +14 −0 subsys/net/l2/ethernet/ethernet.c
@@ -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.
*
@@ -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)
{

0 comments on commit 11b06fa

Please sign in to comment.
You can’t perform that action at this time.