diff options
author | Yunjian Wang <wangyunjian@huawei.com> | 2024-02-02 15:53:20 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2024-02-04 15:42:05 +0000 |
commit | 45a96c407eb1cd44aa0179db8d600015616bcced (patch) | |
tree | 42158021f2090723ebdeebadc460d9d2bc94725d /drivers/net | |
parent | bd8a8d5ec5048ef74002d9f3db5cae971e68712c (diff) | |
download | lwn-45a96c407eb1cd44aa0179db8d600015616bcced.tar.gz lwn-45a96c407eb1cd44aa0179db8d600015616bcced.zip |
tun: Implement ethtool's get_channels() callback
Implement the tun .get_channels functionality. This feature is necessary
for some tools, such as libxdp, which need to retrieve the queue count.
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/tun.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e335ece47dec..b472f2c972d8 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3643,12 +3643,22 @@ static int tun_set_coalesce(struct net_device *dev, return 0; } +static void tun_get_channels(struct net_device *dev, + struct ethtool_channels *channels) +{ + struct tun_struct *tun = netdev_priv(dev); + + channels->combined_count = tun->numqueues; + channels->max_combined = tun->flags & IFF_MULTI_QUEUE ? MAX_TAP_QUEUES : 1; +} + static const struct ethtool_ops tun_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_MAX_FRAMES, .get_drvinfo = tun_get_drvinfo, .get_msglevel = tun_get_msglevel, .set_msglevel = tun_set_msglevel, .get_link = ethtool_op_get_link, + .get_channels = tun_get_channels, .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = tun_get_coalesce, .set_coalesce = tun_set_coalesce, |