diff mbox series

[net-next] tun: Implement ethtool's get_channels() callback

Message ID 1706789109-36556-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tun: Implement ethtool's get_channels() callback | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1048 this patch: 1048
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1065 this patch: 1065
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-01--18-00 (tests: 717)

Commit Message

wangyunjian Feb. 1, 2024, 12:05 p.m. UTC
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>
---
 drivers/net/tun.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jiri Pirko Feb. 1, 2024, 12:57 p.m. UTC | #1
Thu, Feb 01, 2024 at 01:05:09PM CET, wangyunjian@huawei.com wrote:
>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>
Willem de Bruijn Feb. 1, 2024, 3:43 p.m. UTC | #2
Yunjian Wang wrote:
> 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>
> ---
>  drivers/net/tun.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index afa5497f7c35..7cf448ff93ee 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -3638,12 +3638,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 = MAX_TAP_QUEUES;

Conditional on IFF_MULTI_QUEUE?

> +}
> +
>  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,
> -- 
> 2.33.0
>
wangyunjian Feb. 2, 2024, 2:03 a.m. UTC | #3
> -----Original Message-----
> From: Willem de Bruijn [mailto:willemdebruijn.kernel@gmail.com]
> Sent: Thursday, February 1, 2024 11:43 PM
> To: wangyunjian <wangyunjian@huawei.com>;
> willemdebruijn.kernel@gmail.com; jasowang@redhat.com; kuba@kernel.org;
> davem@davemloft.net
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; xudingke
> <xudingke@huawei.com>; wangyunjian <wangyunjian@huawei.com>
> Subject: Re: [PATCH net-next] tun: Implement ethtool's get_channels() callback
> 
> Yunjian Wang wrote:
> > 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>
> > ---
> >  drivers/net/tun.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c index
> > afa5497f7c35..7cf448ff93ee 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -3638,12 +3638,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 = MAX_TAP_QUEUES;
> 
> Conditional on IFF_MULTI_QUEUE?

OK, like this?
   channels->combined_count = tun->numqueues;
   channels->max_combined = tun->flags & IFF_MULTI_QUEUE ? MAX_TAP_QUEUES : 1;

Thanks

> 
> > +}
> > +
> >  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,
> > --
> > 2.33.0
> >
>
diff mbox series

Patch

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index afa5497f7c35..7cf448ff93ee 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -3638,12 +3638,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 = MAX_TAP_QUEUES;
+}
+
 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,