All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters
@ 2022-01-08 18:16 Dario Binacchi
  2022-01-08 20:16 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Dario Binacchi @ 2022-01-08 18:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dario Binacchi, David S. Miller, Jakub Kicinski,
	Marc Kleine-Budde, Wolfgang Grandegger, linux-can, netdev

Adds ethtool support to get the number of message buffers configured for
reception/transmission, which may also depends on runtime configurations
such as the 'rx-rtr' flag state.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

---

 drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/can/flexcan/flexcan-ethtool.c b/drivers/net/can/flexcan/flexcan-ethtool.c
index 5bb45653e1ac..d119bca584f6 100644
--- a/drivers/net/can/flexcan/flexcan-ethtool.c
+++ b/drivers/net/can/flexcan/flexcan-ethtool.c
@@ -80,7 +80,24 @@ static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags)
 	return 0;
 }
 
+static void flexcan_get_ringparam(struct net_device *ndev,
+				  struct ethtool_ringparam *ring)
+{
+	struct flexcan_priv *priv = netdev_priv(ndev);
+
+	ring->rx_max_pending = priv->mb_count;
+	ring->tx_max_pending = priv->mb_count;
+
+	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX)
+		ring->rx_pending = __sw_hweight64(priv->rx_mask);
+	else
+		ring->rx_pending = 6;
+
+	ring->tx_pending = __sw_hweight64(priv->tx_mask);
+}
+
 static const struct ethtool_ops flexcan_ethtool_ops = {
+	.get_ringparam = flexcan_get_ringparam,
 	.get_sset_count = flexcan_get_sset_count,
 	.get_strings = flexcan_get_strings,
 	.get_priv_flags = flexcan_get_priv_flags,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters
  2022-01-08 18:16 [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters Dario Binacchi
@ 2022-01-08 20:16 ` Marc Kleine-Budde
  2022-01-09 11:22   ` Dario Binacchi
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2022-01-08 20:16 UTC (permalink / raw)
  To: Dario Binacchi
  Cc: linux-kernel, David S. Miller, Jakub Kicinski,
	Wolfgang Grandegger, linux-can, netdev

[-- Attachment #1: Type: text/plain, Size: 2471 bytes --]

On 08.01.2022 19:16:33, Dario Binacchi wrote:
> Adds ethtool support to get the number of message buffers configured for
> reception/transmission, which may also depends on runtime configurations
> such as the 'rx-rtr' flag state.
> 
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> ---
> 
>  drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/net/can/flexcan/flexcan-ethtool.c b/drivers/net/can/flexcan/flexcan-ethtool.c
> index 5bb45653e1ac..d119bca584f6 100644
> --- a/drivers/net/can/flexcan/flexcan-ethtool.c
> +++ b/drivers/net/can/flexcan/flexcan-ethtool.c
> @@ -80,7 +80,24 @@ static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags)
>  	return 0;
>  }
>  
> +static void flexcan_get_ringparam(struct net_device *ndev,
> +				  struct ethtool_ringparam *ring)

This doesn't compile on net-next/master, as the prototype of the
get_ringparam callback changed, fixed this while applying.

> +{
> +	struct flexcan_priv *priv = netdev_priv(ndev);
> +
> +	ring->rx_max_pending = priv->mb_count;
> +	ring->tx_max_pending = priv->mb_count;
> +
> +	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX)
> +		ring->rx_pending = __sw_hweight64(priv->rx_mask);

I've replaced the hamming weight calculation by the simpler:

| 		ring->rx_pending = priv->offload.mb_last -
| 			priv->offload.mb_first + 1;

> +	else
> +		ring->rx_pending = 6;
> +
> +	ring->tx_pending = __sw_hweight64(priv->tx_mask);

...and here I added a hardcoded "1", as the driver currently only
support on TX buffer.

> +}
> +
>  static const struct ethtool_ops flexcan_ethtool_ops = {
> +	.get_ringparam = flexcan_get_ringparam,
>  	.get_sset_count = flexcan_get_sset_count,
>  	.get_strings = flexcan_get_strings,
>  	.get_priv_flags = flexcan_get_priv_flags,

BTW: If you're looking for more TX performance, this can be done by
using more than one TX buffer. It's also possible to configure the
number of RX and TX buffers via ethtool during runtime. I'm currently
preparing a patch set for the mcp251xfd to implement this.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters
  2022-01-08 20:16 ` Marc Kleine-Budde
@ 2022-01-09 11:22   ` Dario Binacchi
  2022-01-09 11:37     ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Dario Binacchi @ 2022-01-09 11:22 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: linux-kernel, David S. Miller, Jakub Kicinski,
	Wolfgang Grandegger, linux-can, netdev

On Sat, Jan 8, 2022 at 9:16 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> On 08.01.2022 19:16:33, Dario Binacchi wrote:
> > Adds ethtool support to get the number of message buffers configured for
> > reception/transmission, which may also depends on runtime configurations
> > such as the 'rx-rtr' flag state.
> >
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> >
> > ---
> >
> >  drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/drivers/net/can/flexcan/flexcan-ethtool.c b/drivers/net/can/flexcan/flexcan-ethtool.c
> > index 5bb45653e1ac..d119bca584f6 100644
> > --- a/drivers/net/can/flexcan/flexcan-ethtool.c
> > +++ b/drivers/net/can/flexcan/flexcan-ethtool.c
> > @@ -80,7 +80,24 @@ static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags)
> >       return 0;
> >  }
> >
> > +static void flexcan_get_ringparam(struct net_device *ndev,
> > +                               struct ethtool_ringparam *ring)
>
> This doesn't compile on net-next/master, as the prototype of the
> get_ringparam callback changed, fixed this while applying.
>
> > +{
> > +     struct flexcan_priv *priv = netdev_priv(ndev);
> > +
> > +     ring->rx_max_pending = priv->mb_count;
> > +     ring->tx_max_pending = priv->mb_count;
> > +
> > +     if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX)
> > +             ring->rx_pending = __sw_hweight64(priv->rx_mask);
>
> I've replaced the hamming weight calculation by the simpler:
>
> |               ring->rx_pending = priv->offload.mb_last -
> |                       priv->offload.mb_first + 1;
>
> > +     else
> > +             ring->rx_pending = 6;
> > +
> > +     ring->tx_pending = __sw_hweight64(priv->tx_mask);
>
> ...and here I added a hardcoded "1", as the driver currently only
> support on TX buffer.
>
> > +}
> > +
> >  static const struct ethtool_ops flexcan_ethtool_ops = {
> > +     .get_ringparam = flexcan_get_ringparam,
> >       .get_sset_count = flexcan_get_sset_count,
> >       .get_strings = flexcan_get_strings,
> >       .get_priv_flags = flexcan_get_priv_flags,
>
> BTW: If you're looking for more TX performance, this can be done by
> using more than one TX buffer.

I didn't expect only one message buffer to be used for transmission

thanks and regards,
Dario

> It's also possible to configure the
> number of RX and TX buffers via ethtool during runtime. I'm currently
> preparing a patch set for the mcp251xfd to implement this.
>
> regards,
> Marc
>
> --
> Pengutronix e.K.                 | Marc Kleine-Budde           |
> Embedded Linux                   | https://www.pengutronix.de  |
> Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
> Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |



-- 

Dario Binacchi

Embedded Linux Developer

dario.binacchi@amarulasolutions.com

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
info@amarulasolutions.com

www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters
  2022-01-09 11:22   ` Dario Binacchi
@ 2022-01-09 11:37     ` Marc Kleine-Budde
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2022-01-09 11:37 UTC (permalink / raw)
  To: Dario Binacchi
  Cc: linux-kernel, David S. Miller, Jakub Kicinski,
	Wolfgang Grandegger, linux-can, netdev

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

On 09.01.2022 12:22:54, Dario Binacchi wrote:
> > >  static const struct ethtool_ops flexcan_ethtool_ops = {
> > > +     .get_ringparam = flexcan_get_ringparam,
> > >       .get_sset_count = flexcan_get_sset_count,
> > >       .get_strings = flexcan_get_strings,
> > >       .get_priv_flags = flexcan_get_priv_flags,
> >
> > BTW: If you're looking for more TX performance, this can be done by
> > using more than one TX buffer.
> 
> I didn't expect only one message buffer to be used for transmission

It was easier to implement, but now we've sorted it out how to implement
multiple TX buffers race free and lock-less. Have a look at the
mcp251xfd driver.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-09 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 18:16 [RFC PATCH] can: flexcan: add ethtool support to get rx/tx ring parameters Dario Binacchi
2022-01-08 20:16 ` Marc Kleine-Budde
2022-01-09 11:22   ` Dario Binacchi
2022-01-09 11:37     ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.