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
216 ``ETHTOOL_MSG_PRIVFLAGS_GET_REPLY`` private flags216 ``ETHTOOL_MSG_PRIVFLAGS_GET_REPLY`` private flags
217 ``ETHTOOL_MSG_PRIVFLAGS_NTF`` private flags217 ``ETHTOOL_MSG_PRIVFLAGS_NTF`` private flags
218 ``ETHTOOL_MSG_RINGS_GET_REPLY`` ring sizes218 ``ETHTOOL_MSG_RINGS_GET_REPLY`` ring sizes
219 ``ETHTOOL_MSG_RINGS_NTF`` ring sizes
219 ===================================== =================================220 ===================================== =================================
220 221
221``GET`` requests are sent by userspace applications to retrieve device222``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
55 ETHTOOL_MSG_PRIVFLAGS_GET_REPLY,55 ETHTOOL_MSG_PRIVFLAGS_GET_REPLY,
56 ETHTOOL_MSG_PRIVFLAGS_NTF,56 ETHTOOL_MSG_PRIVFLAGS_NTF,
57 ETHTOOL_MSG_RINGS_GET_REPLY,57 ETHTOOL_MSG_RINGS_GET_REPLY,
58 ETHTOOL_MSG_RINGS_NTF,
58 59
59 /* add new constants above here */60 /* add new constants above here */
60 __ETHTOOL_MSG_KERNEL_CNT,61 __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
1635static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)1635static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1636{1636{
1637 struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM };1637 struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM };
1638 int ret;
1638 1639
1639 if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam)1640 if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam)
1640 return -EOPNOTSUPP;1641 return -EOPNOTSUPP;
@@ -1651,7 +1652,10 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) · 10 unmodified lines
1651 ringparam.tx_pending > max.tx_max_pending)1652 ringparam.tx_pending > max.tx_max_pending)
1652 return -EINVAL;1653 return -EINVAL;
1653 1654
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;
1655}1659}
1656 1660
1657static noinline_for_stack int ethtool_get_channels(struct net_device *dev,1661static 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
532 [ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,532 [ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,
533 [ETHTOOL_MSG_FEATURES_NTF] = &ethnl_features_request_ops,533 [ETHTOOL_MSG_FEATURES_NTF] = &ethnl_features_request_ops,
534 [ETHTOOL_MSG_PRIVFLAGS_NTF] = &ethnl_privflags_request_ops,534 [ETHTOOL_MSG_PRIVFLAGS_NTF] = &ethnl_privflags_request_ops,
535 [ETHTOOL_MSG_RINGS_NTF] = &ethnl_rings_request_ops,
535};536};
536 537
537/* default notification handler */538/* default notification handler */
@@ -619,6 +620,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { · 81 unmodified lines
619 [ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify,620 [ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify,
620 [ETHTOOL_MSG_FEATURES_NTF] = ethnl_default_notify,621 [ETHTOOL_MSG_FEATURES_NTF] = ethnl_default_notify,
621 [ETHTOOL_MSG_PRIVFLAGS_NTF] = ethnl_default_notify,622 [ETHTOOL_MSG_PRIVFLAGS_NTF] = ethnl_default_notify,
623 [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify,
622};624};
623 625
624void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)626void 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
186 }186 }
187 187
188 ret = dev->ethtool_ops->set_ringparam(dev, &ringparam);188 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);
189 192
190out_ops:193out_ops:
191 ethnl_ops_complete(dev);194 ethnl_ops_complete(dev);