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.
Unified · Split
| @@ -216,6 +216,7 @@ Kernel to userspace: · 215 unmodified lines | ||
| 216 | 216 | ``ETHTOOL_MSG_PRIVFLAGS_GET_REPLY`` private flags |
| 217 | 217 | ``ETHTOOL_MSG_PRIVFLAGS_NTF`` private flags |
| 218 | 218 | ``ETHTOOL_MSG_RINGS_GET_REPLY`` ring sizes |
| 219 | + ``ETHTOOL_MSG_RINGS_NTF`` ring sizes | |
| 219 | 220 | ===================================== ================================= |
| 220 | 221 | |
| 221 | 222 | ``GET`` requests are sent by userspace applications to retrieve device |
| @@ -55,6 +55,7 @@ enum { · 54 unmodified lines | ||
| 55 | 55 | ETHTOOL_MSG_PRIVFLAGS_GET_REPLY, |
| 56 | 56 | ETHTOOL_MSG_PRIVFLAGS_NTF, |
| 57 | 57 | ETHTOOL_MSG_RINGS_GET_REPLY, |
| 58 | + ETHTOOL_MSG_RINGS_NTF, | |
| 58 | 59 | |
| 59 | 60 | /* add new constants above here */ |
| 60 | 61 | __ETHTOOL_MSG_KERNEL_CNT, |
| @@ -1635,6 +1635,7 @@ static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) · 1634 unmodified lines | ||
| 1635 | 1635 | static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) |
| 1636 | 1636 | { |
| 1637 | 1637 | struct ethtool_ringparam ringparam, max = { .cmd = ETHTOOL_GRINGPARAM }; |
| 1638 | + int ret; | |
| 1638 | 1639 | |
| 1639 | 1640 | if (!dev->ethtool_ops->set_ringparam || !dev->ethtool_ops->get_ringparam) |
| 1640 | 1641 | return -EOPNOTSUPP; |
| @@ -1651,7 +1652,10 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) · 10 unmodified lines | ||
| 1651 | 1652 | ringparam.tx_pending > max.tx_max_pending) |
| 1652 | 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 | |
| 1657 | 1661 | static noinline_for_stack int ethtool_get_channels(struct net_device *dev, |
| @@ -532,6 +532,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { · 531 unmodified lines | ||
| 532 | 532 | [ETHTOOL_MSG_WOL_NTF] = ðnl_wol_request_ops, |
| 533 | 533 | [ETHTOOL_MSG_FEATURES_NTF] = ðnl_features_request_ops, |
| 534 | 534 | [ETHTOOL_MSG_PRIVFLAGS_NTF] = ðnl_privflags_request_ops, |
| 535 | + [ETHTOOL_MSG_RINGS_NTF] = ðnl_rings_request_ops, | |
| 535 | 536 | }; |
| 536 | 537 | |
| 537 | 538 | /* default notification handler */ |
| @@ -619,6 +620,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { · 81 unmodified lines | ||
| 619 | 620 | [ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify, |
| 620 | 621 | [ETHTOOL_MSG_FEATURES_NTF] = ethnl_default_notify, |
| 621 | 622 | [ETHTOOL_MSG_PRIVFLAGS_NTF] = ethnl_default_notify, |
| 623 | + [ETHTOOL_MSG_RINGS_NTF] = ethnl_default_notify, | |
| 622 | 624 | }; |
| 623 | 625 | |
| 624 | 626 | void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) |
| @@ -186,6 +186,9 @@ int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) · 185 unmodified lines | ||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 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 | |
| 190 | 193 | out_ops: |
| 191 | 194 | ethnl_ops_complete(dev); |