[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKgT0UcMsTFSMdz8h0TttyCn1LmPORX7acGyct+uQGtO1C_9EQ@mail.gmail.com>
Date: Sat, 13 Jul 2024 13:10:31 -0700
From: Alexander Duyck <alexander.duyck@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: netdev@...r.kernel.org, Alexander Duyck <alexanderduyck@...com>, kuba@...nel.org,
davem@...emloft.net, pabeni@...hat.com, edumazet@...gle.com,
kernel-team@...a.com
Subject: Re: [net-next PATCH v5 03/15] eth: fbnic: Allocate core device
specific structures and devlink interface
On Sat, Jul 13, 2024 at 11:50 AM Andrew Lunn <andrew@...n.ch> wrote:
>
> > +int fbnic_alloc_irqs(struct fbnic_dev *fbd)
> > +{
> > + unsigned int wanted_irqs = FBNIC_NON_NAPI_VECTORS;
> > + struct pci_dev *pdev = to_pci_dev(fbd->dev);
> > + int num_irqs;
> > +
> > + wanted_irqs += 1;
> > + num_irqs = pci_alloc_irq_vectors(pdev, FBNIC_NON_NAPI_VECTORS + 1,
> > + wanted_irqs, PCI_IRQ_MSIX);
>
> nit picking, but this is a bit odd. Why not:
>
> > + unsigned int wanted_irqs = FBNIC_NON_NAPI_VECTORS + 1;
> > + num_irqs = pci_alloc_irq_vectors(pdev, wanted_irqs,
> > + wanted_irqs, PCI_IRQ_MSIX);
The the min and max diverge once we add NAPI vectors to the equation.
For now it is wanted_irqs += 1 to avoid an issue with wanted_irqs/max
being less than (NON_NAPI_VECTORS + 1)/min.
The final format after patch 7 is:
wanted_irqs += min_t(unsigned int, num_online_cpus(), FBNIC_MAX_RXQS);
num_irqs = pci_alloc_irq_vectors(pdev, FBNIC_NON_NAPI_VECTORS + 1,
wanted_irqs, PCI_IRQ_MSIX);
> > + if (num_irqs < 0) {
> > + dev_err(fbd->dev, "Failed to allocate MSI-X entries\n");
> > + return num_irqs;
> > + }
> > +
> > + if (num_irqs < wanted_irqs)
> > + dev_warn(fbd->dev, "Allocated %d IRQs, expected %d\n",
> > + num_irqs, wanted_irqs);
>
> https://elixir.bootlin.com/linux/latest/source/drivers/pci/msi/api.c#L206
>
> * Return: number of allocated vectors (which might be smaller than
> * @max_vecs), -ENOSPC if less than @min_vecs interrupt vectors are
> * available, other errnos otherwise.
>
> So i don't think this is possible.
>
> Andrew
I agree it isn't with the current state. However after adding patch 7
it is definitely possible. This is basically just enabling support for
the NAPI interrupt vectors that will be introduced in patch 7.
Powered by blists - more mailing lists