History

ethtool: add RINGS_NTF notification

Send ETHTOOL_MSG_RINGS_NTF notification whenever ring sizes of a network device are modified using ETHTOOL_MSG_RINGS_SET netlink message or ETHTOOL_SRINGPARAM ioctl request.

Michal Kubecek committed 6 years ago

Commit bc9d1c91 parent 2fc29295 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/rings.c +3 −0
Documentation/networking/ethtool-netlink.rst+1−0
@@ -216,6 +216,7 @@ Kernel to userspace: · 215 unmodified lines
216216 ``ETHTOOL_MSG_PRIVFLAGS_GET_REPLY`` private flags
217217 ``ETHTOOL_MSG_PRIVFLAGS_NTF`` private flags
218218 ``ETHTOOL_MSG_RINGS_GET_REPLY`` ring sizes
219+ ``ETHTOOL_MSG_RINGS_NTF`` ring sizes
219220 ===================================== =================================
220221
221222 ``GET`` requests are sent by userspace applications to retrieve device
include/uapi/linux/ethtool_netlink.h+1−0
@@ -55,6 +55,7 @@ enum { · 54 unmodified lines
5555 ETHTOOL_MSG_PRIVFLAGS_GET_REPLY,
5656 ETHTOOL_MSG_PRIVFLAGS_NTF,
5757 ETHTOOL_MSG_RINGS_GET_REPLY,
58+ ETHTOOL_MSG_RINGS_NTF,
5859
5960 /* add new constants above here */
6061 __ETHTOOL_MSG_KERNEL_CNT,
net/ethtool/ioctl.c+5−1
@@ -1635,6 +1635,7 @@ static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) · 1634 unmodified lines
16351635 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
16361636 {
16371637 struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM };
1638+ int ret;
16381639
16391640 if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam)
16401641 return -EOPNOTSUPP;
@@ -1651,7 +1652,10 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) · 10 unmodified lines
16511652 ringparam.tx_pending > max.tx_max_pending)
16521653 return -EINVAL;
16531654
1654− return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1655+ ret = dev->ethtool_ops->set_ringparam(dev, &ringparam);
1656+ if (!ret)
1657+ ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF, NULL);
1658+ return ret;
16551659 }
16561660
16571661 static noinline_for_stack int ethtool_get_channels(struct net_device *dev,
net/ethtool/netlink.c+2−0
@@ -532,6 +532,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { · 531 unmodified lines
532532 [ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,
533533 [ETHTOOL_MSG_FEATURES_NTF] = &ethnl_features_request_ops,
534534 [ETHTOOL_MSG_PRIVFLAGS_NTF] = &ethnl_privflags_request_ops,
535+ [ETHTOOL_MSG_RINGS_NTF] = &ethnl_rings_request_ops,
535536 };
536537
537538 /* default notification handler */
@@ -619,6 +620,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { · 81 unmodified lines
619620 [ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify,
620621 [ETHTOOL_MSG_FEATURES_NTF] = ethnl_default_notify,
621622 [ETHTOOL_MSG_PRIVFLAGS_NTF] = ethnl_default_notify,
623+ [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify,
622624 };
623625
624626 void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
net/ethtool/rings.c+3−0
@@ -186,6 +186,9 @@ int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) · 185 unmodified lines
186186 }
187187
188188 ret = dev->ethtool_ops->set_ringparam(dev, &ringparam);
189+ if (ret < 0)
190+ goto out_ops;
191+ ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF, NULL);
189192
190193 out_ops:
191194 ethnl_ops_complete(dev);