diff mbox series

[v2,bpf-next,13/17] veth: implement ethtool's get_channels() callback

Message ID 20210311152910.56760-14-maciej.fijalkowski@intel.com
State Superseded
Headers show
Series AF_XDP selftests improvements & bpf_link | expand

Commit Message

Maciej Fijalkowski March 11, 2021, 3:29 p.m. UTC
Libbpf's xsk part calls get_channels() API to retrieve the queue count
of the underlying driver so that XSKMAP is sized accordingly.

Implement that in veth so multi queue scenarios can work properly.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 drivers/net/veth.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Magnus Karlsson March 16, 2021, 8:44 a.m. UTC | #1
On Thu, Mar 11, 2021 at 4:43 PM Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>

> Libbpf's xsk part calls get_channels() API to retrieve the queue count

> of the underlying driver so that XSKMAP is sized accordingly.

>

> Implement that in veth so multi queue scenarios can work properly.

>

> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> ---

>  drivers/net/veth.c | 12 ++++++++++++

>  1 file changed, 12 insertions(+)

>

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c

> index aa1a66ad2ce5..efca3d45f5c2 100644

> --- a/drivers/net/veth.c

> +++ b/drivers/net/veth.c

> @@ -218,6 +218,17 @@ static void veth_get_ethtool_stats(struct net_device *dev,

>         }

>  }

>

> +static void veth_get_channels(struct net_device *dev,

> +                             struct ethtool_channels *channels)

> +{

> +       channels->tx_count = dev->real_num_tx_queues;

> +       channels->rx_count = dev->real_num_rx_queues;

> +       channels->max_tx = dev->real_num_tx_queues;

> +       channels->max_rx = dev->real_num_rx_queues;

> +       channels->combined_count = min(dev->real_num_rx_queues, dev->real_num_rx_queues);

> +       channels->max_combined = min(dev->real_num_rx_queues, dev->real_num_rx_queues);


Copy and paste error in the above two lines. One of the min entries
should be dev->real_num_tx_queues. Kind of pointless otherwise ;-).

> +}

> +

>  static const struct ethtool_ops veth_ethtool_ops = {

>         .get_drvinfo            = veth_get_drvinfo,

>         .get_link               = ethtool_op_get_link,

> @@ -226,6 +237,7 @@ static const struct ethtool_ops veth_ethtool_ops = {

>         .get_ethtool_stats      = veth_get_ethtool_stats,

>         .get_link_ksettings     = veth_get_link_ksettings,

>         .get_ts_info            = ethtool_op_get_ts_info,

> +       .get_channels           = veth_get_channels,

>  };

>

>  /* general routines */

> --

> 2.20.1

>
Maciej Fijalkowski March 22, 2021, 8:10 p.m. UTC | #2
On Tue, Mar 16, 2021 at 09:44:38AM +0100, Magnus Karlsson wrote:
> On Thu, Mar 11, 2021 at 4:43 PM Maciej Fijalkowski

> <maciej.fijalkowski@intel.com> wrote:

> >

> > Libbpf's xsk part calls get_channels() API to retrieve the queue count

> > of the underlying driver so that XSKMAP is sized accordingly.

> >

> > Implement that in veth so multi queue scenarios can work properly.

> >

> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> > ---

> >  drivers/net/veth.c | 12 ++++++++++++

> >  1 file changed, 12 insertions(+)

> >

> > diff --git a/drivers/net/veth.c b/drivers/net/veth.c

> > index aa1a66ad2ce5..efca3d45f5c2 100644

> > --- a/drivers/net/veth.c

> > +++ b/drivers/net/veth.c

> > @@ -218,6 +218,17 @@ static void veth_get_ethtool_stats(struct net_device *dev,

> >         }

> >  }

> >

> > +static void veth_get_channels(struct net_device *dev,

> > +                             struct ethtool_channels *channels)

> > +{

> > +       channels->tx_count = dev->real_num_tx_queues;

> > +       channels->rx_count = dev->real_num_rx_queues;

> > +       channels->max_tx = dev->real_num_tx_queues;

> > +       channels->max_rx = dev->real_num_rx_queues;

> > +       channels->combined_count = min(dev->real_num_rx_queues, dev->real_num_rx_queues);

> > +       channels->max_combined = min(dev->real_num_rx_queues, dev->real_num_rx_queues);

> 

> Copy and paste error in the above two lines. One of the min entries

> should be dev->real_num_tx_queues. Kind of pointless otherwise ;-).


Geez. Embarrassing :)

> 

> > +}

> > +

> >  static const struct ethtool_ops veth_ethtool_ops = {

> >         .get_drvinfo            = veth_get_drvinfo,

> >         .get_link               = ethtool_op_get_link,

> > @@ -226,6 +237,7 @@ static const struct ethtool_ops veth_ethtool_ops = {

> >         .get_ethtool_stats      = veth_get_ethtool_stats,

> >         .get_link_ksettings     = veth_get_link_ksettings,

> >         .get_ts_info            = ethtool_op_get_ts_info,

> > +       .get_channels           = veth_get_channels,

> >  };

> >

> >  /* general routines */

> > --

> > 2.20.1

> >
diff mbox series

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index aa1a66ad2ce5..efca3d45f5c2 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -218,6 +218,17 @@  static void veth_get_ethtool_stats(struct net_device *dev,
 	}
 }
 
+static void veth_get_channels(struct net_device *dev,
+			      struct ethtool_channels *channels)
+{
+	channels->tx_count = dev->real_num_tx_queues;
+	channels->rx_count = dev->real_num_rx_queues;
+	channels->max_tx = dev->real_num_tx_queues;
+	channels->max_rx = dev->real_num_rx_queues;
+	channels->combined_count = min(dev->real_num_rx_queues, dev->real_num_rx_queues);
+	channels->max_combined = min(dev->real_num_rx_queues, dev->real_num_rx_queues);
+}
+
 static const struct ethtool_ops veth_ethtool_ops = {
 	.get_drvinfo		= veth_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
@@ -226,6 +237,7 @@  static const struct ethtool_ops veth_ethtool_ops = {
 	.get_ethtool_stats	= veth_get_ethtool_stats,
 	.get_link_ksettings	= veth_get_link_ksettings,
 	.get_ts_info		= ethtool_op_get_ts_info,
+	.get_channels		= veth_get_channels,
 };
 
 /* general routines */