History

ethtool: add PAUSE_NTF notification

Send ETHTOOL_MSG_PAUSE_NTF notification whenever pause parameters of a network device are modified using ETHTOOL_MSG_PAUSE_SET netlink message or ETHTOOL_SPAUSEPARAM ioctl request.

Michal Kubecek committed 6 years ago

Commit bf37faa1 parent 3ab87995 files · +12 −1Browse files

Unified · Split

5 files
  1. Documentation/networking/ethtool-netlink.rst +1 −0
  2. include/uapi/linux/ethtool_netlink.h +1 −0
  3. net/ethtool/ioctl.c +5 −1
  4. net/ethtool/netlink.c +2 −0
  5. net/ethtool/pause.c +3 −0
Documentation/networking/ethtool-netlink.rst+1−0
@@ -228,6 +228,7 @@ Kernel to userspace: · 227 unmodified lines
228 ``ETHTOOL_MSG_COALESCE_GET_REPLY`` coalescing parameters228 ``ETHTOOL_MSG_COALESCE_GET_REPLY`` coalescing parameters
229 ``ETHTOOL_MSG_COALESCE_NTF`` coalescing parameters229 ``ETHTOOL_MSG_COALESCE_NTF`` coalescing parameters
230 ``ETHTOOL_MSG_PAUSE_GET_REPLY`` pause parameters230 ``ETHTOOL_MSG_PAUSE_GET_REPLY`` pause parameters
231 ``ETHTOOL_MSG_PAUSE_NTF`` pause parameters
231 ===================================== =================================232 ===================================== =================================
232 233
233``GET`` requests are sent by userspace applications to retrieve device234``GET`` requests are sent by userspace applications to retrieve device
include/uapi/linux/ethtool_netlink.h+1−0
@@ -67,6 +67,7 @@ enum { · 66 unmodified lines
67 ETHTOOL_MSG_COALESCE_GET_REPLY,67 ETHTOOL_MSG_COALESCE_GET_REPLY,
68 ETHTOOL_MSG_COALESCE_NTF,68 ETHTOOL_MSG_COALESCE_NTF,
69 ETHTOOL_MSG_PAUSE_GET_REPLY,69 ETHTOOL_MSG_PAUSE_GET_REPLY,
70 ETHTOOL_MSG_PAUSE_NTF,
70 71
71 /* add new constants above here */72 /* add new constants above here */
72 __ETHTOOL_MSG_KERNEL_CNT,73 __ETHTOOL_MSG_KERNEL_CNT,
net/ethtool/ioctl.c+5−1
@@ -1705,6 +1705,7 @@ static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) · 1704 unmodified lines
1705static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)1705static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
1706{1706{
1707 struct ethtool_pauseparam pauseparam;1707 struct ethtool_pauseparam pauseparam;
1708 int ret;
1708 1709
1709 if (!dev->ethtool_ops->set_pauseparam)1710 if (!dev->ethtool_ops->set_pauseparam)
1710 return -EOPNOTSUPP;1711 return -EOPNOTSUPP;
@@ -1712,7 +1713,10 @@ static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr) · 1 unmodified line
1712 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))1713 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
1713 return -EFAULT;1714 return -EFAULT;
1714 1715
1715 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);1716 ret = dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
1717 if (!ret)
1718 ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF, NULL);
1719 return ret;
1716}1720}
1717 1721
1718static int ethtool_self_test(struct net_device *dev, char __user *useraddr)1722static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
net/ethtool/netlink.c+2−0
@@ -546,6 +546,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { · 545 unmodified lines
546 [ETHTOOL_MSG_RINGS_NTF] = &ethnl_rings_request_ops,546 [ETHTOOL_MSG_RINGS_NTF] = &ethnl_rings_request_ops,
547 [ETHTOOL_MSG_CHANNELS_NTF] = &ethnl_channels_request_ops,547 [ETHTOOL_MSG_CHANNELS_NTF] = &ethnl_channels_request_ops,
548 [ETHTOOL_MSG_COALESCE_NTF] = &ethnl_coalesce_request_ops,548 [ETHTOOL_MSG_COALESCE_NTF] = &ethnl_coalesce_request_ops,
549 [ETHTOOL_MSG_PAUSE_NTF] = &ethnl_pause_request_ops,
549};550};
550 551
551/* default notification handler */552/* default notification handler */
@@ -636,6 +637,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { · 84 unmodified lines
636 [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify,637 [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify,
637 [ETHTOOL_MSG_CHANNELS_NTF] = ethnl_default_notify,638 [ETHTOOL_MSG_CHANNELS_NTF] = ethnl_default_notify,
638 [ETHTOOL_MSG_COALESCE_NTF] = ethnl_default_notify,639 [ETHTOOL_MSG_COALESCE_NTF] = ethnl_default_notify,
640 [ETHTOOL_MSG_PAUSE_NTF] = ethnl_default_notify,
639};641};
640 642
641void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)643void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
net/ethtool/pause.c+3−0
@@ -131,6 +131,9 @@ int ethnl_set_pause(struct sk_buff *skb, struct genl_info *info) · 130 unmodified lines
131 goto out_ops;131 goto out_ops;
132 132
133 ret = dev->ethtool_ops->set_pauseparam(dev, &params);133 ret = dev->ethtool_ops->set_pauseparam(dev, &params);
134 if (ret < 0)
135 goto out_ops;
136 ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF, NULL);
134 137
135out_ops:138out_ops:
136 ethnl_ops_complete(dev);139 ethnl_ops_complete(dev);