Hi,
I'm sorry for late reply, too.
On 2015/05/18 22:05, Christos Zoulas wrote:
> On May 18, 3:57pm,
k-nak...@iij.ad.jp (Kengo NAKAHARA) wrote:
> -- Subject: Re: change MSI/MSI-X APIs
> I am fine with it; just some clarifications:
>
> - by max (-1) I meant the maximum number that the bus will allow. The driver
> would then decide how to split the interrupts amongst functions.
OK, I implemented such "max" number.
> - I considered using unsigned int/size_t in the counts argument and then
> I thought that it is best if it agreed with the return type, since we
> overload the return type with (negative error/positive number of interrupts).
> Another way to do this would be to return the number of interrupts allocated
> in the 0'th member of the counts array.
I implemented like latter way, but I think 0'th member may cause
confusion. So, I implemented that the function sets really allocated
counts to the same member of the counts array.
e.g. if the driver call pci_intr_alloc() in following way
====================
int counts[PCI_INTR_TYPE_SIZE];
counts[PCI_INTR_TYPE_MSIX] = 5;
counts[PCI_INTR_TYPE_MSI] = 1;
counts[PCI_INTR_TYPE_INTX] = 1;
error = pci_intr_alloc(pa, ihps, counts, PCI_INTR_TYPE_MSIX);
====================
on success of MSI-X allocation, "counts" is overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 5;
counts[PCI_INTR_TYPE_MSI] == 0;
counts[PCI_INTR_TYPE_INTX] == 0;
====================
on failed MSI-X but success of MSI allocation, "counts" is
overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 0;
counts[PCI_INTR_TYPE_MSI] == 1;
counts[PCI_INTR_TYPE_INTX] == 0;
====================
on failed MSI-X and MSI, but success of INTx allocation,
"counts" is overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 0;
counts[PCI_INTR_TYPE_MSI] == 0;
counts[PCI_INTR_TYPE_INTX] == 1;
====================
on failed (of all allocation functions), pci_intr_alloc() returns
non-zero value, and the all members of "counts" are 0.
On success, the driver can also use below simple way
====================
allocated_count = counts[pci_intr_type(intr_handlers[0]);
====================
Thus, here is the implementation of above specification (include man)
http://netbsd.org/~knakahara/unify-alloc-api/unify-alloc-api.patch
furthermore, here is if_wm usage example by msaitoh@n.o
http://netbsd.org/~knakahara/unify-alloc-api/unify-alloc-api-wm-example.patch
Could you comment this patch?