RE: [PATCH] [RFC] net: fec: Allow turning off IRQ coalescing
From: Wei Fang
Date: Mon Feb 20 2023 - 20:40:49 EST
> -----Original Message-----
> From: Richard Weinberger <richard@xxxxxx>
> Sent: 2023年2月21日 4:15
> To: Wei Fang <wei.fang@xxxxxxx>
> Cc: netdev <netdev@xxxxxxxxxxxxxxx>; linux-kernel
> <linux-kernel@xxxxxxxxxxxxxxx>; pabeni <pabeni@xxxxxxxxxx>; kuba
> <kuba@xxxxxxxxxx>; edumazet <edumazet@xxxxxxxxxx>; davem
> <davem@xxxxxxxxxxxxx>; dl-linux-imx <linux-imx@xxxxxxx>; Clark Wang
> <xiaoning.wang@xxxxxxx>; Shenwei Wang <shenwei.wang@xxxxxxx>
> Subject: Re: [PATCH] [RFC] net: fec: Allow turning off IRQ coalescing
>
> Wei Fang,
>
> ----- Ursprüngliche Mail -----
> > Von: "wei fang" <wei.fang@xxxxxxx>
> >> /* Set threshold for interrupt coalescing */ -static void
> >> fec_enet_itr_coal_set(struct net_device *ndev)
> >> +static int fec_enet_itr_coal_set(struct net_device *ndev)
> >> {
> >> + bool disable_rx_itr = false, disable_tx_itr = false;
> >> struct fec_enet_private *fep = netdev_priv(ndev);
> > disable_rx_itr should be defined below fep to follow the style of the
> > reverse Christmas tree.
>
> Of course, will fix in v2.
>
> >> - int rx_itr, tx_itr;
> >> + struct device *dev = &fep->pdev->dev;
> >> + int rx_itr = 0, tx_itr = 0;
> >>
> >> - /* Must be greater than zero to avoid unpredictable behavior */
> >> - if (!fep->rx_time_itr || !fep->rx_pkts_itr ||
> >> - !fep->tx_time_itr || !fep->tx_pkts_itr)
> >> - return;
> >> + if (!fep->rx_time_itr || !fep->rx_pkts_itr) {
> >> + if (fep->rx_time_itr || fep->rx_pkts_itr) {
> >
> > I think the below should be better:
> > if (!!fep->rx_time_itr == ! fep->rx_pkts_itr)
>
> At least it's shorter. :-)
> I'm not sure which variant is easier to understand, though.
>
> But in general you are fine with returning -EINVAL in this case?
> I'm asking because that a userspace visible change.
>
I think it's fine to return -EINVAL. For hardware, one of the two parameters
is 0 is an invalid value with the interrupt coalescing enabled, and the behavior
of hardware is unpredictable.