-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: phy: provide phylib stubs for hardware timestamping operations
net/core/dev_ioctl.c (built-in code) will want to call phy_mii_ioctl() for hardware timestamping purposes. This is not directly possible, because phy_mii_ioctl() is a symbol provided under CONFIG_PHYLIB. Do something similar to what was done in DSA in commit 5a17818 ("net: dsa: replace NETDEV_PRE_CHANGE_HWTSTAMP notifier with a stub"), and arrange some indirect calls to phy_mii_ioctl() through a stub structure containing function pointers, that's provided by phylib as built-in even when CONFIG_PHYLIB=m, and which phy_init() populates at runtime (module insertion). Note: maybe the ownership of the ethtool_phy_ops singleton is backwards, and the methods exposed by that should be later merged into phylib_stubs. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20230801142824.1772134-12-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Vladimir Oltean
authored and
Jakub Kicinski
committed
Aug 3, 2023
1 parent
70ef7d8
commit 60495b6
Showing
7 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* Stubs for PHY library functionality called by the core network stack. | ||
* These are necessary because CONFIG_PHYLIB can be a module, and built-in | ||
* code cannot directly call symbols exported by modules. | ||
*/ | ||
#include <linux/phylib_stubs.h> | ||
|
||
const struct phylib_stubs *phylib_stubs; | ||
EXPORT_SYMBOL_GPL(phylib_stubs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
/* | ||
* Stubs for the Network PHY library | ||
*/ | ||
|
||
#include <linux/rtnetlink.h> | ||
|
||
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); | ||
}; | ||
|
||
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); | ||
} | ||
|
||
#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; | ||
} | ||
|
||
#endif |