mirror of https://gitee.com/openkylin/linux.git
ethtool: set pause parameters with PAUSE_SET request
Implement PAUSE_SET netlink request to set pause parameters of a network device. Thease are traditionally set with ETHTOOL_SPAUSEPARAM ioctl request. Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7f59fb32b0
commit
3ab879933d
|
@ -200,6 +200,7 @@ Userspace to kernel:
|
||||||
``ETHTOOL_MSG_COALESCE_GET`` get coalescing parameters
|
``ETHTOOL_MSG_COALESCE_GET`` get coalescing parameters
|
||||||
``ETHTOOL_MSG_COALESCE_SET`` set coalescing parameters
|
``ETHTOOL_MSG_COALESCE_SET`` set coalescing parameters
|
||||||
``ETHTOOL_MSG_PAUSE_GET`` get pause parameters
|
``ETHTOOL_MSG_PAUSE_GET`` get pause parameters
|
||||||
|
``ETHTOOL_MSG_PAUSE_SET`` set pause parameters
|
||||||
===================================== ================================
|
===================================== ================================
|
||||||
|
|
||||||
Kernel to userspace:
|
Kernel to userspace:
|
||||||
|
@ -899,7 +900,7 @@ have their netlink replacement yet.
|
||||||
``ETHTOOL_GRINGPARAM`` ``ETHTOOL_MSG_RINGS_GET``
|
``ETHTOOL_GRINGPARAM`` ``ETHTOOL_MSG_RINGS_GET``
|
||||||
``ETHTOOL_SRINGPARAM`` ``ETHTOOL_MSG_RINGS_SET``
|
``ETHTOOL_SRINGPARAM`` ``ETHTOOL_MSG_RINGS_SET``
|
||||||
``ETHTOOL_GPAUSEPARAM`` ``ETHTOOL_MSG_PAUSE_GET``
|
``ETHTOOL_GPAUSEPARAM`` ``ETHTOOL_MSG_PAUSE_GET``
|
||||||
``ETHTOOL_SPAUSEPARAM`` n/a
|
``ETHTOOL_SPAUSEPARAM`` ``ETHTOOL_MSG_PAUSE_SET``
|
||||||
``ETHTOOL_GRXCSUM`` ``ETHTOOL_MSG_FEATURES_GET``
|
``ETHTOOL_GRXCSUM`` ``ETHTOOL_MSG_FEATURES_GET``
|
||||||
``ETHTOOL_SRXCSUM`` ``ETHTOOL_MSG_FEATURES_SET``
|
``ETHTOOL_SRXCSUM`` ``ETHTOOL_MSG_FEATURES_SET``
|
||||||
``ETHTOOL_GTXCSUM`` ``ETHTOOL_MSG_FEATURES_GET``
|
``ETHTOOL_GTXCSUM`` ``ETHTOOL_MSG_FEATURES_GET``
|
||||||
|
|
|
@ -35,6 +35,7 @@ enum {
|
||||||
ETHTOOL_MSG_COALESCE_GET,
|
ETHTOOL_MSG_COALESCE_GET,
|
||||||
ETHTOOL_MSG_COALESCE_SET,
|
ETHTOOL_MSG_COALESCE_SET,
|
||||||
ETHTOOL_MSG_PAUSE_GET,
|
ETHTOOL_MSG_PAUSE_GET,
|
||||||
|
ETHTOOL_MSG_PAUSE_SET,
|
||||||
|
|
||||||
/* add new constants above here */
|
/* add new constants above here */
|
||||||
__ETHTOOL_MSG_USER_CNT,
|
__ETHTOOL_MSG_USER_CNT,
|
||||||
|
|
|
@ -809,6 +809,11 @@ static const struct genl_ops ethtool_genl_ops[] = {
|
||||||
.dumpit = ethnl_default_dumpit,
|
.dumpit = ethnl_default_dumpit,
|
||||||
.done = ethnl_default_done,
|
.done = ethnl_default_done,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.cmd = ETHTOOL_MSG_PAUSE_SET,
|
||||||
|
.flags = GENL_UNS_ADMIN_PERM,
|
||||||
|
.doit = ethnl_set_pause,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
|
static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
|
||||||
|
|
|
@ -353,5 +353,6 @@ int ethnl_set_privflags(struct sk_buff *skb, struct genl_info *info);
|
||||||
int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info);
|
int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info);
|
||||||
int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info);
|
int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info);
|
||||||
int ethnl_set_coalesce(struct sk_buff *skb, struct genl_info *info);
|
int ethnl_set_coalesce(struct sk_buff *skb, struct genl_info *info);
|
||||||
|
int ethnl_set_pause(struct sk_buff *skb, struct genl_info *info);
|
||||||
|
|
||||||
#endif /* _NET_ETHTOOL_NETLINK_H */
|
#endif /* _NET_ETHTOOL_NETLINK_H */
|
||||||
|
|
|
@ -79,3 +79,64 @@ const struct ethnl_request_ops ethnl_pause_request_ops = {
|
||||||
.reply_size = pause_reply_size,
|
.reply_size = pause_reply_size,
|
||||||
.fill_reply = pause_fill_reply,
|
.fill_reply = pause_fill_reply,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* PAUSE_SET */
|
||||||
|
|
||||||
|
static const struct nla_policy
|
||||||
|
pause_set_policy[ETHTOOL_A_PAUSE_MAX + 1] = {
|
||||||
|
[ETHTOOL_A_PAUSE_UNSPEC] = { .type = NLA_REJECT },
|
||||||
|
[ETHTOOL_A_PAUSE_HEADER] = { .type = NLA_NESTED },
|
||||||
|
[ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 },
|
||||||
|
[ETHTOOL_A_PAUSE_RX] = { .type = NLA_U8 },
|
||||||
|
[ETHTOOL_A_PAUSE_TX] = { .type = NLA_U8 },
|
||||||
|
};
|
||||||
|
|
||||||
|
int ethnl_set_pause(struct sk_buff *skb, struct genl_info *info)
|
||||||
|
{
|
||||||
|
struct nlattr *tb[ETHTOOL_A_PAUSE_MAX + 1];
|
||||||
|
struct ethtool_pauseparam params = {};
|
||||||
|
struct ethnl_req_info req_info = {};
|
||||||
|
const struct ethtool_ops *ops;
|
||||||
|
struct net_device *dev;
|
||||||
|
bool mod = false;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = nlmsg_parse(info->nlhdr, GENL_HDRLEN, tb, ETHTOOL_A_PAUSE_MAX,
|
||||||
|
pause_set_policy, info->extack);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
ret = ethnl_parse_header_dev_get(&req_info,
|
||||||
|
tb[ETHTOOL_A_PAUSE_HEADER],
|
||||||
|
genl_info_net(info), info->extack,
|
||||||
|
true);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
dev = req_info.dev;
|
||||||
|
ops = dev->ethtool_ops;
|
||||||
|
ret = -EOPNOTSUPP;
|
||||||
|
if (!ops->get_pauseparam || !ops->set_pauseparam)
|
||||||
|
goto out_dev;
|
||||||
|
|
||||||
|
rtnl_lock();
|
||||||
|
ret = ethnl_ops_begin(dev);
|
||||||
|
if (ret < 0)
|
||||||
|
goto out_rtnl;
|
||||||
|
ops->get_pauseparam(dev, ¶ms);
|
||||||
|
|
||||||
|
ethnl_update_bool32(¶ms.autoneg, tb[ETHTOOL_A_PAUSE_AUTONEG], &mod);
|
||||||
|
ethnl_update_bool32(¶ms.rx_pause, tb[ETHTOOL_A_PAUSE_RX], &mod);
|
||||||
|
ethnl_update_bool32(¶ms.tx_pause, tb[ETHTOOL_A_PAUSE_TX], &mod);
|
||||||
|
ret = 0;
|
||||||
|
if (!mod)
|
||||||
|
goto out_ops;
|
||||||
|
|
||||||
|
ret = dev->ethtool_ops->set_pauseparam(dev, ¶ms);
|
||||||
|
|
||||||
|
out_ops:
|
||||||
|
ethnl_ops_complete(dev);
|
||||||
|
out_rtnl:
|
||||||
|
rtnl_unlock();
|
||||||
|
out_dev:
|
||||||
|
dev_put(dev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue