1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Stubs for the Network PHY library
*/
#include <linux/rtnetlink.h>
struct ethtool_eth_phy_stats;
struct ethtool_link_ext_stats;
struct ethtool_phy_stats;
struct kernel_hwtstamp_config;
struct netlink_ext_ack;
struct phy_device;
#if IS_ENABLED(CONFIG_PHYLIB)
extern const struct phylib_stubs *phylib_stubs;
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)
{
}
#endif
|