can: flexcan: add ethtool support to get rx/tx ring parameters
Subsystems (3)
RFC PATCH 1/1 can: flexcan: add ethtool support to get rx/tx ring parameters
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.
---
drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/can/flexcan/flexcan-ethtool.c +17 -0
@@ -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,
Signature · 1 line
2.32.0
Marc Kleine-Budde
maintainerQuoted 16 lines · Dario Binacchi
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 <[email protected]>---
drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/net/can/flexcan/flexcan-ethtool.c +0
-0
drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 84
Quoted 5 lines
drivers/net/can/flexcan/flexcan-ethtool.c +2
-0@@ -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.
drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 92
Quoted 8 lines
drivers/net/can/flexcan/flexcan-ethtool.c +8
-0+{ +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;
drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 96
Quoted 4 lines
drivers/net/can/flexcan/flexcan-ethtool.c +4
-0+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.
drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 103
Quoted 7 lines
drivers/net/can/flexcan/flexcan-ethtool.c +3
-0+} +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
Signature · 4 lines
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 |
Quoted 49 lines · Marc Kleine-Budde
Quoted 16 lines · Dario Binacchi
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 <[email protected]>---
drivers/net/can/flexcan/flexcan-ethtool.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/net/can/flexcan/flexcan-ethtool.c +0
-0drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 84
Quoted 5 lines
drivers/net/can/flexcan/flexcan-ethtool.c +2
-0@@ -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_ringparamcallback changed, fixed this while applying.drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 92
Quoted 8 lines
drivers/net/can/flexcan/flexcan-ethtool.c +8
-0+{ +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;drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 96
Quoted 4 lines
drivers/net/can/flexcan/flexcan-ethtool.c +4
-0+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.
Quoted 10 lines
drivers/net/can/flexcan/flexcan-ethtool.c static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags) · line 103
Quoted 7 lines
drivers/net/can/flexcan/flexcan-ethtool.c +3
-0+} +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
Quoted 12 lines
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 |
Signature · 17 lines
Dario Binacchi Embedded Linux Developer [email protected] __________________________________ Amarula Solutions SRL Via Le Canevare 30, 31100 Treviso, Veneto, IT T. +39 042 243 5310 [email protected] www.amarulasolutions.com
Marc Kleine-Budde
maintainerQuoted 10 lines · Dario Binacchi
Quoted 8 lines
Quoted 5 lines
static const struct
ethtool_opsflexcan_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
Signature · 4 lines
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 |