[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBLqQmj4FoMAsNsh@corigine.com>
Date: Thu, 16 Mar 2023 11:06:58 +0100
From: Simon Horman <simon.horman@...igine.com>
To: Markus Schneider-Pargmann <msp@...libre.com>
Cc: Marc Kleine-Budde <mkl@...gutronix.de>,
Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
Wolfgang Grandegger <wg@...ndegger.com>,
Vincent MAILHOL <mailhol.vincent@...adoo.fr>,
linux-can@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 10/16] can: m_can: Add tx coalescing ethtool support
On Wed, Mar 15, 2023 at 12:05:40PM +0100, Markus Schneider-Pargmann wrote:
> Add get/set functions for ethtool coalescing. tx-frames-irq and
> tx-usecs-irq can only be set/unset together. tx-frames-irq needs to be
> less than TXE and TXB.
Perhaps I'm reading this wrong (maybe I need a coffee). But I think it
might be a bit clearer to call out the TX aspect of this patch up front (I
know it is in the subject.
Maybe something like this:
Add TX support to get/set functions for ethtool coalescing...
>
> As rx and tx share the same timer, rx-usecs-irq and tx-usecs-irq can be
> enabled/disabled individually but they need to have the same value if
> enabled.
>
> Signed-off-by: Markus Schneider-Pargmann <msp@...libre.com>
Nits above and below not withstanding,
Reviewed-by: Simon Horman <simon.horman@...igine.com>
> ---
> drivers/net/can/m_can/m_can.c | 38 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 7f8decfae81e..4e794166664a 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1945,6 +1945,8 @@ static int m_can_get_coalesce(struct net_device *dev,
>
> ec->rx_max_coalesced_frames_irq = cdev->rx_max_coalesced_frames_irq;
> ec->rx_coalesce_usecs_irq = cdev->rx_coalesce_usecs_irq;
> + ec->tx_max_coalesced_frames_irq = cdev->tx_max_coalesced_frames_irq;
> + ec->tx_coalesce_usecs_irq = cdev->tx_coalesce_usecs_irq;
>
> return 0;
> }
> @@ -1971,16 +1973,50 @@ static int m_can_set_coalesce(struct net_device *dev,
> netdev_err(dev, "rx-frames-irq and rx-usecs-irq can only be set together\n");
> return -EINVAL;
> }
> + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXE].num) {
> + netdev_err(dev, "tx-frames-irq %u greater than the TX event FIFO %u\n",
> + ec->tx_max_coalesced_frames_irq,
> + cdev->mcfg[MRAM_TXE].num);
> + return -EINVAL;
> + }
> + if (ec->tx_max_coalesced_frames_irq > cdev->mcfg[MRAM_TXB].num) {
> + netdev_err(dev, "tx-frames-irq %u greater than the TX FIFO %u\n",
> + ec->tx_max_coalesced_frames_irq,
> + cdev->mcfg[MRAM_TXB].num);
> + return -EINVAL;
> + }
> + if ((ec->tx_max_coalesced_frames_irq == 0) != (ec->tx_coalesce_usecs_irq == 0)) {
> + netdev_err(dev, "tx-frames-irq and tx-usecs-irq can only be set together\n");
> + return -EINVAL;
> + }
nit: checkpatch complains about unnecessary parentheses
drivers/net/can/m_can/m_can.c:1988: CHECK: Unnecessary parentheses around 'ec->tx_max_coalesced_frames_irq == 0'
+ if ((ec->tx_max_coalesced_frames_irq == 0) != (ec->tx_coalesce_usecs_irq == 0)) {
drivers/net/can/m_can/m_can.c:1988: CHECK: Unnecessary parentheses around 'ec->tx_coalesce_usecs_irq == 0'
+ if ((ec->tx_max_coalesced_frames_irq == 0) != (ec->tx_coalesce_usecs_irq == 0)) {
> + if (ec->rx_coalesce_usecs_irq != 0 && ec->tx_coalesce_usecs_irq != 0 &&
> + ec->rx_coalesce_usecs_irq != ec->tx_coalesce_usecs_irq) {
> + netdev_err(dev, "rx-usecs-irq %u needs to be equal to tx-usecs-irq %u if both are enabled\n",
> + ec->rx_coalesce_usecs_irq,
> + ec->tx_coalesce_usecs_irq);
> + return -EINVAL;
> + }
>
> cdev->rx_max_coalesced_frames_irq = ec->rx_max_coalesced_frames_irq;
> cdev->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq;
> + cdev->tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq;
> + cdev->tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq;
> +
> + if (cdev->rx_coalesce_usecs_irq)
> + cdev->irq_timer_wait =
> + ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC);
> + else
> + cdev->irq_timer_wait =
> + ns_to_ktime(cdev->tx_coalesce_usecs_irq * NSEC_PER_USEC);
nit: perhaps adding us_to_ktime() and using it treewide would be interesting
> return 0;
> }
>
> static const struct ethtool_ops m_can_ethtool_ops = {
> .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ |
> - ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ,
> + ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ |
> + ETHTOOL_COALESCE_TX_USECS_IRQ |
> + ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ,
> .get_ts_info = ethtool_op_get_ts_info,
> .get_coalesce = m_can_get_coalesce,
> .set_coalesce = m_can_set_coalesce,
> --
> 2.39.2
>
Powered by blists - more mailing lists