Skip to content

Commit 45a96c4

Browse files
wyjwangdavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bd8a8d5 commit 45a96c4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/net/tun.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,12 +3643,22 @@ static int tun_set_coalesce(struct net_device *dev,
36433643
return 0;
36443644
}
36453645

3646+
static void tun_get_channels(struct net_device *dev,
3647+
struct ethtool_channels *channels)
3648+
{
3649+
struct tun_struct *tun = netdev_priv(dev);
3650+
3651+
channels->combined_count = tun->numqueues;
3652+
channels->max_combined = tun->flags & IFF_MULTI_QUEUE ? MAX_TAP_QUEUES : 1;
3653+
}
3654+
36463655
static const struct ethtool_ops tun_ethtool_ops = {
36473656
.supported_coalesce_params = ETHTOOL_COALESCE_RX_MAX_FRAMES,
36483657
.get_drvinfo = tun_get_drvinfo,
36493658
.get_msglevel = tun_get_msglevel,
36503659
.set_msglevel = tun_set_msglevel,
36513660
.get_link = ethtool_op_get_link,
3661+
.get_channels = tun_get_channels,
36523662
.get_ts_info = ethtool_op_get_ts_info,
36533663
.get_coalesce = tun_get_coalesce,
36543664
.set_coalesce = tun_set_coalesce,

0 commit comments

Comments
 (0)