Commit 45a96c40 authored by Yunjian Wang's avatar Yunjian Wang Committed by David S. Miller
Browse files

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: default avatarYunjian Wang <wangyunjian@huawei.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd8a8d5e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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,