-
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: ethtool: netlink: Add support for triggering a cable test
Add new ethtool netlink calls to trigger the starting of a PHY cable test. Add Kconfig'ury to ETHTOOL_NETLINK so that PHYLIB is not a module when ETHTOOL_NETLINK is builtin, which would result in kernel linking errors. v2: Remove unwanted white space change Remove ethnl_cable_test_act_ops and use doit handler Rename cable_test_set_policy cable_test_act_policy Remove ETHTOOL_MSG_CABLE_TEST_ACT_REPLY v3: Remove ETHTOOL_MSG_CABLE_TEST_ACT_REPLY from documentation Remove unused cable_test_get_policy Add Reviewed-by tags v4: Remove unwanted blank line Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Michal Kubecek <mkubecek@suse.cz> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Andrew Lunn
authored and
Jakub Kicinski
committed
May 10, 2020
1 parent
97c2243
commit 11ca3c4
Showing
7 changed files
with
89 additions
and
2 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,54 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
|
||
#include <linux/phy.h> | ||
#include "netlink.h" | ||
#include "common.h" | ||
|
||
/* CABLE_TEST_ACT */ | ||
|
||
static const struct nla_policy | ||
cable_test_act_policy[ETHTOOL_A_CABLE_TEST_MAX + 1] = { | ||
[ETHTOOL_A_CABLE_TEST_UNSPEC] = { .type = NLA_REJECT }, | ||
[ETHTOOL_A_CABLE_TEST_HEADER] = { .type = NLA_NESTED }, | ||
}; | ||
|
||
int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) | ||
{ | ||
struct nlattr *tb[ETHTOOL_A_CABLE_TEST_MAX + 1]; | ||
struct ethnl_req_info req_info = {}; | ||
struct net_device *dev; | ||
int ret; | ||
|
||
ret = nlmsg_parse(info->nlhdr, GENL_HDRLEN, tb, | ||
ETHTOOL_A_CABLE_TEST_MAX, | ||
cable_test_act_policy, info->extack); | ||
if (ret < 0) | ||
return ret; | ||
|
||
ret = ethnl_parse_header_dev_get(&req_info, | ||
tb[ETHTOOL_A_CABLE_TEST_HEADER], | ||
genl_info_net(info), info->extack, | ||
true); | ||
if (ret < 0) | ||
return ret; | ||
|
||
dev = req_info.dev; | ||
if (!dev->phydev) { | ||
ret = -EOPNOTSUPP; | ||
goto out_dev_put; | ||
} | ||
|
||
rtnl_lock(); | ||
ret = ethnl_ops_begin(dev); | ||
if (ret < 0) | ||
goto out_rtnl; | ||
|
||
ret = phy_start_cable_test(dev->phydev, info->extack); | ||
|
||
ethnl_ops_complete(dev); | ||
out_rtnl: | ||
rtnl_unlock(); | ||
out_dev_put: | ||
dev_put(dev); | ||
return ret; | ||
} |
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