include/linux/phylib_stubs.h

Source file repositories/reference/linux-study-clean/include/linux/phylib_stubs.h

File Facts

System
Linux kernel
Corpus path
include/linux/phylib_stubs.h
Extension
.h
Size
2700 bytes
Lines
111
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct phylib_stubs {
	int (*hwtstamp_get)(struct phy_device *phydev,
			    struct kernel_hwtstamp_config *config);
	int (*hwtstamp_set)(struct phy_device *phydev,
			    struct kernel_hwtstamp_config *config,
			    struct netlink_ext_ack *extack);
	void (*get_phy_stats)(struct phy_device *phydev,
			      struct ethtool_eth_phy_stats *phy_stats,
			      struct ethtool_phy_stats *phydev_stats);
	void (*get_link_ext_stats)(struct phy_device *phydev,
				   struct ethtool_link_ext_stats *link_stats);
};

static inline int phy_hwtstamp_get(struct phy_device *phydev,
				   struct kernel_hwtstamp_config *config)
{
	/* phylib_register_stubs() and phylib_unregister_stubs()
	 * also run under rtnl_lock().
	 */
	ASSERT_RTNL();

	if (!phylib_stubs)
		return -EOPNOTSUPP;

	return phylib_stubs->hwtstamp_get(phydev, config);
}

static inline int phy_hwtstamp_set(struct phy_device *phydev,
				   struct kernel_hwtstamp_config *config,
				   struct netlink_ext_ack *extack)
{
	/* phylib_register_stubs() and phylib_unregister_stubs()
	 * also run under rtnl_lock().
	 */
	ASSERT_RTNL();

	if (!phylib_stubs)
		return -EOPNOTSUPP;

	return phylib_stubs->hwtstamp_set(phydev, config, extack);
}

static inline void phy_ethtool_get_phy_stats(struct phy_device *phydev,
					struct ethtool_eth_phy_stats *phy_stats,
					struct ethtool_phy_stats *phydev_stats)
{
	ASSERT_RTNL();

	if (!phylib_stubs)
		return;

	phylib_stubs->get_phy_stats(phydev, phy_stats, phydev_stats);
}

static inline void phy_ethtool_get_link_ext_stats(struct phy_device *phydev,
				    struct ethtool_link_ext_stats *link_stats)
{
	ASSERT_RTNL();

	if (!phylib_stubs)
		return;

	phylib_stubs->get_link_ext_stats(phydev, link_stats);
}

#else

static inline int phy_hwtstamp_get(struct phy_device *phydev,
				   struct kernel_hwtstamp_config *config)
{
	return -EOPNOTSUPP;
}

static inline int phy_hwtstamp_set(struct phy_device *phydev,
				   struct kernel_hwtstamp_config *config,
				   struct netlink_ext_ack *extack)
{
	return -EOPNOTSUPP;
}

static inline void phy_ethtool_get_phy_stats(struct phy_device *phydev,
					struct ethtool_eth_phy_stats *phy_stats,
					struct ethtool_phy_stats *phydev_stats)
{
}

static inline void phy_ethtool_get_link_ext_stats(struct phy_device *phydev,
				    struct ethtool_link_ext_stats *link_stats)
{
}

Annotation

Implementation Notes