Subject: Re: [PATCH mlx5-next 1/4] PCI: Configure number of MSI-X vectors for SR-IOV VFs

From: Leon Romanovsky <[email-masked]>
Date: Sun, 10 Jan 2021 10:33:45 +0200

On Fri, Jan 08, 2021 at 09:54:47PM -0500, Don Dutile wrote:
> On 1/8/21 4:09 PM, Bjorn Helgaas wrote:
> > On Thu, Jan 07, 2021 at 10:54:38PM -0500, Don Dutile wrote:
> > > On 1/7/21 7:57 PM, Bjorn Helgaas wrote:
> > > > On Sun, Jan 03, 2021 at 10:24:37AM +0200, Leon Romanovsky wrote:
> > > > > + **/
> > > > > +int pci_set_msix_vec_count(struct pci_dev *dev, int numb)
> > > > > +{
> > > > > +	struct pci_dev *pdev = pci_physfn(dev);
> > > > > +
> > > > > +	if (!dev->msix_cap || !pdev->msix_cap)
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	if (dev->driver || !pdev->driver ||
> > > > > +	    !pdev->driver->sriov_set_msix_vec_count)
> > > > > +		return -EOPNOTSUPP;
> > > > > +
> > > > > +	if (numb < 0)
> > > > > +		/*
> > > > > +		 * We don't support negative numbers for now,
> > > > > +		 * but maybe in the future it will make sense.
> > > > > +		 */
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	return pdev->driver->sriov_set_msix_vec_count(dev, numb);
> > > > So we write to a VF sysfs file, get here and look up the PF, call a PF
> > > > driver callback with the VF as an argument, the callback (at least for
> > > > mlx5) looks up the PF from the VF, then does some mlx5-specific magic
> > > > to the PF that influences the VF somehow?
> > > There's no PF lookup above.... it's just checking if a pdev has a
> > > driver with the desired msix-cap setting(reduction) feature.
> > We started with the VF (the sysfs file is attached to the VF).  "pdev"
> > is the corresponding PF; that's what I meant by "looking up the PF".
> > Then we call the PF driver sriov_set_msix_vec_count() method.
> ah, got how your statement relates to the files &/or pdev.
>
> > I asked because this raises questions of whether we need mutual
> > exclusion or some other coordination between setting this for multiple
> > VFs.
> >
> > Obviously it's great to answer all these in email, but at the end of
> > the day, the rationale needs to be in the commit, either in code
> > comments or the commit log.
> >
> I'm still not getting why this is not per-(vf)pdev -- just b/c a device has N-number of MSIX capability doesn't mean it has to all be used/configured,
> Setting max-MSIX for VFs in the PF's pdev means it is the same number for all VFs ... and I'm not sure that's the right solution either.
> It should still be (v)pdev-based, IMO.

The proposed solution is per-VF, am I missing anything in this discussion?

> --dd