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
228228 ``ETHTOOL_MSG_COALESCE_GET_REPLY`` coalescing parameters
229229 ``ETHTOOL_MSG_COALESCE_NTF`` coalescing parameters
230230 ``ETHTOOL_MSG_PAUSE_GET_REPLY`` pause parameters
231+ ``ETHTOOL_MSG_PAUSE_NTF`` pause parameters
231232 ===================================== =================================
232233
233234 ``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
6767 ETHTOOL_MSG_COALESCE_GET_REPLY,
6868 ETHTOOL_MSG_COALESCE_NTF,
6969 ETHTOOL_MSG_PAUSE_GET_REPLY,
70+ ETHTOOL_MSG_PAUSE_NTF,
7071
7172 /* add new constants above here */
7273 __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
17051705 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
17061706 {
17071707 struct ethtool_pauseparam pauseparam;
1708+ int ret;
17081709
17091710 if (!dev->ethtool_ops->set_pauseparam)
17101711 return -EOPNOTSUPP;
@@ -1712,7 +1713,10 @@ static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr) · 1 unmodified line
17121713 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
17131714 return -EFAULT;
17141715
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;
17161720 }
17171721
17181722 static 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
546546 [ETHTOOL_MSG_RINGS_NTF] = &ethnl_rings_request_ops,
547547 [ETHTOOL_MSG_CHANNELS_NTF] = &ethnl_channels_request_ops,
548548 [ETHTOOL_MSG_COALESCE_NTF] = &ethnl_coalesce_request_ops,
549+ [ETHTOOL_MSG_PAUSE_NTF] = &ethnl_pause_request_ops,
549550 };
550551
551552 /* default notification handler */
@@ -636,6 +637,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { · 84 unmodified lines
636637 [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify,
637638 [ETHTOOL_MSG_CHANNELS_NTF] = ethnl_default_notify,
638639 [ETHTOOL_MSG_COALESCE_NTF] = ethnl_default_notify,
640+ [ETHTOOL_MSG_PAUSE_NTF] = ethnl_default_notify,
639641 };
640642
641643 void 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
131131 goto out_ops;
132132
133133 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);
134137
135138 out_ops:
136139 ethnl_ops_complete(dev);